Capstrano部署的Rails找不到已安装的捆绑程序版本

juud5qan  于 2022-10-15  发布在  Ruby
关注(0)|答案(1)|浏览(146)

我正在尝试将我的项目的Ruby版本从2.3.1升级到2.7.6。但Capstrano部署失败,并显示以下错误:

$ 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

我安装了正确的bundler版本,并删除了默认版本。当前状态:

$ 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)

Gemfile.lock的结尾:

BUNDLED WITH
   1.17.2

我不知道在这里该怎么办。我在互联网上发现了类似的问题,但没有一个人有解决方案。

9rnv2umw

9rnv2umw1#

最终通过升级RubyGems解决:

gem update --system

看起来更新的RubyGems版本更新了bundler的加载方式。

相关问题