こんにちは。たなか(@tanaka_ricecake)です。
Ruby on RailsでWebアプリケーションサービスの開発をしています。
開発中以下のようなエラーに遭遇したので、内容と解決方法をご紹介します。
もくじ
Could not find ‘bundler’ (2.0.2) required by your /app/Gemfile.lock. (Gem::GemNotFoundException)
bundle install時にエラー
bundle installコマンドを実行時に以下のようなエラーメッセージが表示され、コマンドが正常に処理されませんでした。
# bundle install
Traceback (most recent call last):
2: from /usr/local/bin/bundle:23:in `<main>'
1: from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.0.2) required by your /app/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.0.2`
解決方法
ひとまず言われた通りにする!
エラーメッセージに以下のコマンドを試してみろとあるので、正直に従います。
# gem install bundler:2.0.2
# bundle update --bundler
上記コマンドが実行完了後、以下のようなメッセージが表示されました。
HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.
Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.
For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
Post-install message from chromedriver-helper:
+--------------------------------------------------------------------+
| |
| NOTICE: chromedriver-helper is deprecated after 2019-03-31. |
| |
| Please update to use the 'webdrivers' gem instead. |
| See https://github.com/flavorjones/chromedriver-helper/issues/83 |
| |
+--------------------------------------------------------------------+
Post-install message from sass:
Ruby Sass has reached end-of-life and should no longer be used.
* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
primary implementation: https://sass-lang.com/install
* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
sassc gem: https://github.com/sass/sassc-ruby#readme
* For more details, please refer to the Sass blog:
https://sass-lang.com/blog/posts/7828841
config.i18n.fallbacksについての注意喚起。
RailsGuide 5.2.2によると、‘config.i18n.fallbacks’というファイルで従来の書き方ができなくなるので注意とのことみたいです。
ひとまず一旦無視してサーバーの起動を確かめます。
root@fd354d4e12ef:/app# rails s
=> Booting Puma
=> Rails 5.2.3 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
rails sコマンドが無事に通るようになりました! よかったー!
原因としてはbundlerのバージョンと、Gemfile.lockで指定されているバージョンが一致していないことが問題だったみたいです。
Could not find ‘bundler’ (2.0.2) でコマンドが通らない! まとめ
Railsの実装については業務の中で徐々に理解が深まっている気がしていますが、こういった環境整備系のエラーってサービスを始める時にしか必要にならず、ぶち当たる頻度が少なめなので疎かになりがちですね。
まだまだ根本的には理解できないんだなーと再確認しました。精進せねばです。
今回はここまで。