質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

1052閲覧

RailsにてLoadErrorが発生します 恐らくバージョンダウンのせい?

kyotoinrn

総合スコア23

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2019/01/24 13:52

前提・実現したいこと

Railsで以下のコマンドを実行したところ、次のようなエラーが出てきます。

Railsの書籍を見ながらやっていたんですが、現在のRailsのバージョンは5.2ですがその本は5.1
でした。

`bundle exec rails _5.1.3_ new ./ -B -d mysql --skip-turbolinks --skip-test`

と実行したのですが、バージョンが5.2のままになっていたのでGemfileを途中で修正し、

gem 'rails', '5.1.3'

`bundle update` `bundle install`

としました。

エラーメッセージで調べたところ、多分バージョンをいじったことが関係していると思うんですが、
どうやって直せばよいのか分かっていません、わかる方いらしたらご教授ください。

発生している問題・エラーメッセージ

/mnt/c/Users/ryota/environment/RailsSampleApp$ EDITOR=vim bin/rails secrets:edit /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': cannot load such file -- active_storage/engine (LoadError) from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:292:in `block in require' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:258:in `load_dependency' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:292:in `require' from /mnt/c/Users/ryota/environment/RailsSampleApp/config/application.rb:8:in `<main>' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:292:in `block in require' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:258:in `load_dependency' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:292:in `require' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/command/actions.rb:15:in `require_application_and_environment!' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands/secrets/secrets_command.rb:31:in `edit' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/command/base.rb:63:in `perform' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/command.rb:44:in `invoke' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands.rb:16:in `<main>' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:292:in `block in require' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:258:in `load_dependency' from /mnt/c/Users/ryota/environment/RailsSampleApp/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:292:in `require' from bin/rails:4:in `<main>' ubuntu0876@sarn:/mnt/c/Users/ryota/environment/RailsSampleApp$

該当のソースコード

Ruby

1ソースコード

試したこと

ここに問題に対して試したことを記載してください。

補足情報(FW/ツールのバージョンなど)

ここにより詳細な情報を記載してください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

ActiveStorageは、Rails 5.2にしかない機能です。

途中でバージョンを書き換えると、(特に、バージョンダウンや4.2→5.2のようにバージョンを飛ばした場合には)このようなGemの不整合が起きることがあります。

「書籍を見ながらや」るような状況を考えれば、1からrails newし直したほうがいいでしょう。

投稿2019/01/24 13:55

maisumakun

総合スコア145121

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

maisumakun

2019/01/24 13:57

Gemfileに「gem 'rails', '~>5.1.0'」とだけ書いた状態でbundle installしてからbin/rails newすれば、確実にそのバージョンのRailsで動きます。
kyotoinrn

2019/01/25 00:28

素早いご回答ありがとうございます! やはりそうですよね。具体的には、`rails db:setup` とかがだめだったかなと思うんですが… `rails db:rollback` 等試してみて駄目だったら、やり直そうと思います。
kyotoinrn

2019/01/25 01:28 編集

上手くいかなかったので言われたとおりやり直そうかと思います。 こういう場合っておとなしくやり直すのが一番なんでしょうか…? 追記 VSCodeで一括検索すると、いろんなファイルにactive_storage/engineが残ってしまっていますね、 以後気を付けます。 途中でのGemfileの変更(gem 'rails')はrailsのファイルには変更を与えてくれないのでしょうか?
maisumakun

2019/01/25 01:30

> 途中でのGemfileの変更(gem 'rails')はrailsのファイルには変更を与えてくれないのでしょうか? はい、ファイル生成は「rails new」の時点で行われますので、あとからバージョンを書き換えてもファイルは書き換わりません。
kyotoinrn

2019/01/25 01:39

ありがとうございます。 Gemfileを一掃し、 `gem 'rails', '5.1.3'`とした後、(`bundle install`の後) `bundle exec rails _5.1.3_ new ./ -B -d mysql --skip-turbolinks --skip-test` をしても、 /mnt/c/Users/ryota/environment/RailsSampleApp/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError) from /mnt/c/Users/ryota/environment/RailsSampleApp/config/boot.rb:4:in `<top (required)>' from bin/rails:3:in `require_relative' from bin/rails:3:in `<main>' というエラーが出てきます。bootファイルということは、よくわかりませんが多分完全に最初から始める必要があるということですかね?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問