travis ciで`require': cannot load such file -- bundler/dep_proxy (LoadError)が発生したときの対処法
はじめに
- bundler 1.16.1 と rubygems 2.7.3 で発生します。
- rubygems 2.7.4 で解消されています。
発生したエラー
$ bin/rails db:create RAILS_ENV=test
Traceback (most recent call last):
21: from bin/rails:3:in `<main>'
20: from bin/rails:3:in `require_relative'
19: from /home/travis/build/tsujiguchi/niku18/config/boot.rb:3:in `<top (required)>'
18: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
17: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
16: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
15: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/setup.rb:10:in `<top (required)>'
14: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
13: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:20:in `setup'
12: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:108:in `block in definition_method'
11: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:226:in `requested_specs'
10: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:237:in `specs_for'
9: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:170:in `specs'
8: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:247:in `resolve'
7: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:806:in `converge_locked_specs'
6: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:874:in `expand_dependencies'
5: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:874:in `each'
4: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:887:in `block in expand_dependencies'
3: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:887:in `each'
2: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/definition.rb:888:in `block (2 levels) in expand_dependencies'
1: from /home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/home/travis/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler/dep_proxy (LoadError)
確認
.travis ciでテストを実行すると bundler --version
と gem version
が実行されるのでそれを確認すると以下のようになっています。
$ bundle --version
Bundler version 1.16.1
$ gem --version
2.7.3
対応
.travis.yml
に以下を追加します。
before_install:
- gem update --system --no-document
travisのgemアップデートなので、ドキュメント不要のオプションを付けてます。
gemバージョンアップの確認
$ gem --version
2.7.3
$ gem update --system --no-document
Updating rubygems-update
Fetching: rubygems-update-2.7.4.gem (100%)
Successfully installed rubygems-update-2.7.4
Installing RubyGems 2.7.4
Bundler 1.16.0 installed
RubyGems 2.7.4 installed
Regenerating binstubs
------------------------------------------------------------------------------
RubyGems installed the following executables:
/home/travis/.rvm/rubies/ruby-2.5.0/bin/gem
/home/travis/.rvm/rubies/ruby-2.5.0/bin/bundle
RubyGems system software updated
$ gem --version
2.7.4
2.7.4にアップデートされ、エラーも解消されました。