由于 ruby 条消息,Capistrano 部署失败

Capistrano deploy fails due to ruby messages

我正在尝试使用 capistrano 3.4.0 和 capistrano-rails 1.1.6 部署我的应用程序,但似乎在资产清单期间,当命令复制 .sprockets-manifest.json 运行,不知何故 ruby 消息与突击队员混合并导致部署失败。

以前发生过这种情况,我可以通过将 sprockets gem 降级到 2.8 版来修复它,但是我使用的是 rails 4.2.4,它至少需要 sprockets 版本 3。

下面是命令和输出,如果你能帮助我,我会很高兴。

提前致谢

INFO [19795580] Running /usr/bin/env cp RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,  you can ignore these warnings with 'rvm rvmrc warning ignore /var/www/apps/meetings/releases/20160216200613/Gemfile'.  To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.    /var/www/apps/meetings/releases/20160216200613/public/assets/.sprockets-manifest-5435a7146eb18edb8a835b87bffff57b.json /var/www/apps/meetings/releases/20160216200613/assets_manifest_backup as user@server
DEBUG [19795580] Command: cd /var/www/apps/meetings/releases/20160216200613 && /usr/bin/env cp RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,  you can ignore these warnings with 'rvm rvmrc warning ignore /var/www/apps/meetings/releases/20160216200613/Gemfile'.  To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.    /var/www/apps/meetings/releases/20160216200613/public/assets/.sprockets-manifest-5435a7146eb18edb8a835b87bffff57b.json /var/www/apps/meetings/releases/20160216200613/assets_manifest_backup
DEBUG [19795580]    RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore /var/www/apps/meetings/releases/20160216200613/Gemfile'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.

DEBUG [19795580]    cp: cannot stat ‘RVM’: No such file or directory
cp: cannot stat ‘used’: No such file or directory
cp: cannot stat ‘your’: No such file or directory
cp: cannot stat ‘for’: No such file or directory
cp: cannot stat ‘selecting’: No such file or directory
cp: cannot stat ‘Ruby,’: No such file or directory
cp: cannot stat ‘it’: No such file or directory
cp: cannot stat ‘is’: No such file or directory
cp: cannot stat ‘all’: No such file or directory
cp: cannot stat ‘fine’: No such file or directory
cp: cannot stat ‘-’: No such file or directory
cp: cannot stat ‘Heroku’: No such file or directory
cp: cannot stat ‘does’: No such file or directory
cp: cannot stat ‘that’: No such file or directory
...
...

Rails 4+ 对某些 gem 的特定版本非常挑剔。尝试将您的 gemfile 更新为以下内容:

group :development, :test do
  gem 'capistrano', '~> 3.4.0'
  gem 'capistrano-rvm'
  gem 'capistrano-bundler', '~> 1.1.2'
  gem 'capistrano-rails', '~> 1.1'
  gem 'capistrano-passenger'
end

好的。这个问题是因为 rvm 覆盖了 cd 命令,以便在 Gemfile 中提供一些关于 ruby 版本控制的信息,当 capistrano-rails 运行s 清单备份任务时,它 运行s 一个进入应用程序项目文件夹的 cd 命令,并且 rvm 信息也返回并且部署因此引发了 en 错误。

要解决这个问题,

rvm rvmrc warning ignore allGemfiles

可以是 运行 并且可以在服务器范围内禁用 rvm 消息,或者您可以在项目的根路径中创建一个名为 .ruby-version 的文件并设置 ruby里面的版本。例如:

2.2.4

据我了解。ruby-version 用于 rbenv,但不知何故它也禁用了 rvm 消息。

希望它对其他人也有帮助