Ruby-on-rails Rails 4, Capistrano 3.0.0, 无法加载此类文件 -- deploy

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19247818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 22:50:18  来源:igfitidea点击:

Rails 4, Capistrano 3.0.0, cannot load such file -- deploy

ruby-on-railsruby-on-rails-4capistrano

提问by markhorrocks

I just ran bundle update and capistrano got updated to 3.0.0 but now when I run cap deploy I get an error and can't figure out how to fix this. I have been updating my server every day without problem until this update.

我刚刚运行了 bundle update 并且 capistrano 更新到了 3.0.0 但是现在当我运行 cap deploy 我得到一个错误并且无法弄清楚如何解决这个问题。在此更新之前,我每天都在毫无问题地更新我的服务器。

cap aborted!
cannot load such file -- deploy
/home/mark/rails_apps/myapp/Capfile:1:in `load'
/home/mark/rails_apps/myapp/Capfile:1:in `<top (required)>'

capfile

文件

load 'deploy'
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks

采纳答案by pastullo

I had to run gem uninstall capistrano

我不得不跑 gem uninstall capistrano

then update the gemfile with gem 'capistrano', '~> 2.15'

然后用 gem 'capistrano', '~> 2.15'

and then run to reinstall the correct version again with bundle update capistrano

然后运行以再次重新安装正确的版本 bundle update capistrano

回答by markhorrocks

I had to gem uninstall capistrano and selected version 3.0.0

我不得不 gem 卸载 capistrano 并选择版本 3.0.0

(i.e. downgraded the gem to 2.x)

(即将 gem 降级到 2.x)

回答by stebooks

Make sure you are using bundle exec (most likely you have multiple gem versions of capistrano)

确保您使用的是 bundle exec(很可能您有多个 gem 版本的 capistrano)

i.e.

IE

bundle exec cap -T

bundle exec cap -T

回答by H6.

Instead of downgrading to Capistrano 2 use the new configuration from the current version.

使用当前版本的新配置,而不是降级到 Capistrano 2。

require "capistrano/bundler"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"

See also this nice posting, which summarises the differences between Capistrano 2 and 3.

另请参阅这篇不错的帖子,其中总结了 Capistrano 2 和 3 之间的差异。

回答by reto

Add the related gems to your Gemfile

将相关的宝石添加到您的 Gemfile

i.e. for

即为

gem 'capistrano-bundler' # for capistrano/bundler
gem 'capistrano-rails' # for capistrano/rails/*

Do not downgrade to 2.x for this.

不要为此降级到 2.x。

回答by Meli

I had this problem today and pastullo's solution above fixed it except that I had to run gem uninstall capistrano (as markhorrocks answered) not bundle uninstall capistrano.

我今天遇到了这个问题,上面的 Pastullo 解决方案修复了它,只是我必须运行 gem uninstall capistrano (如 markhorrocks 回答)而不是 bundle uninstall capistrano。

I also found this blog on bundler very useful: http://viget.com/extend/bundler-best-practices

我还发现这个关于 bundler 的博客非常有用:http: //viget.com/extend/bundler-best-practices

Thanks for sharing this as it saved me heaps of time. x

感谢分享这个,因为它为我节省了大量时间。X

回答by user1130176

The fastest way to fix this I have found is to backup the cap files (Capfile, config/deploy.rb, and config/deploy/*.rb) and then re capify (it's no longer called "capify"):

我发现解决此问题的最快方法是备份 cap 文件(Capfile、config/deploy.rb 和 config/deploy/*.rb),然后重新进行 capify(不再称为“capify”):

bundle exec cap install STAGES=staging,production

Then recreate your cap files from your backup. It will take you 5 minutes to do this and you'll be over the major Capistrano upgrade hump.

然后从备份中重新创建 cap 文件。完成此操作需要 5 分钟,您将完成主要的 Capistrano 升级过程。

回答by Alexander Gorg

I used

我用了

bundle exec cap production deploy

bundle exec cap production deploy

instead of just cap production deploy

而不仅仅是 cap production deploy

回答by Alupotha

in my case I have changed my project ruby version. may be bundlealso work here.

就我而言,我已经更改了我的项目 ruby​​ 版本。也可能在bundle这里工作。

but I changed it to back what it was in previously.

但我把它改成以前的样子。

ex:

前任:

rbenv local 2.4.1