Rails 4, Capistrano 3.0.0, cannot load such file —

2019-01-21 18:36发布

问题:

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.

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

回答1:

I had to run gem uninstall capistrano

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

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



回答2:

I had to gem uninstall capistrano and selected version 3.0.0

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



回答3:

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

i.e.

bundle exec cap -T



回答4:

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

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.



回答5:

Add the related gems to your Gemfile

i.e. for

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

Do not downgrade to 2.x for this.



回答6:

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.

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

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



回答7:

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"):

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.



回答8:

I used

bundle exec cap production deploy

instead of just cap production deploy



回答9:

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

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

ex:

rbenv local 2.4.1