I am trying to upgrade Ruby version of my project from 2.3.1 to 2.7.6. But Capistrano deployment fails with this error:
$ cap app_name deploy
* executing "cd /path/to/app/app_name/releases/20221005131513 && bundle install --gemfile /path/to/app/app_name/releases/20221005131513/Gemfile --path /path/to/app/app_name/shared/bundle --deployment --quiet --without development test"
*** [err :: app_name.example.com] /usr/local/rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe'
*** [err :: app_name.example.com] :
*** [err :: app_name.example.com] Could not find 'bundler' (1.17.2) required by your /path/to/app_name/releases/20221005131513/Gemfile.lock.
*** [err :: app_name.example.com] (
*** [err :: app_name.example.com] Gem::GemNotFoundException
*** [err :: app_name.example.com] )
*** [err :: app_name.example.com]
*** [err :: app_name.example.com] To update to the latest version installed on your system, run `bundle update --bundler`.
*** [err :: app_name.example.com] To install the missing version, run `gem install bundler:1.17.2`
*** [err :: app_name.example.com] from /usr/local/rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
*** [err :: app_name.example.com] from /usr/local/rvm/rubies/ruby-2.7.6/bin/bundle:23:in `<main>'
failed: "env PATH=/usr/local/rvm/gems/ruby-2.7.6@global:/usr/local/rvm/rubies/ruby-2.7.6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin sh -c 'cd /path/to/app_name/releases/20221005131513 && bundle install --gemfile /path/to/app_name/releases/20221005131513/Gemfile --path /path/to/app_name/shared/bundle --deployment --quiet --without development test'" on app_name.example.com
I installed the right version of bundler and deleted the default one. Present state:
$ rvm use 2.7.6
Using /usr/local/rvm/gems/ruby-2.7.6
$ bundler -v
Bundler version 1.17.2
$ which bundle
/usr/local/rvm/gems/ruby-2.7.6/bin/bundle
$ gem list bundler
*** LOCAL GEMS ***
bundler (1.17.2)
End of Gemfile.lock:
BUNDLED WITH
1.17.2
I don't know what to do here. I found similar problems on the internet, but none of them had a solution.
CodePudding user response:
Finally resolved by upgrading RubyGems:
gem update --system
Looks like newer RubyGems versions updated the way bundler is loaded.