capistrano / rails

Official Ruby on Rails specific tasks for Capistrano
http://www.capistranorb.com/
MIT License
867 stars 270 forks source link

LoadError: cannot load such file -- capistrano/rails #241

Closed dvodvo closed 4 years ago

dvodvo commented 4 years ago

Steps to reproduce

gem file as follows:

gem "capistrano", "~> 3.10", require: false
gem "capistrano-rails", "~> 1.4", require: false
gem 'capistrano-passenger'
gem 'capistrano-rbenv', '~> 2.1'
gem 'capistrano-bundler', '~> 1.6'

capfile only deploys when commented out:
# require "capistrano/rails"

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

Expected behavior

I expected, according to the ReadMe file to require everything or individually to have migrations run and/or assets pre-compiled, in either development or production mode (I have the same set-up with the same rails version (5.2.4) and ruby (2.6.1) on multiple applications; the behaviour is consistent)

Actual behavior

getting errors as follows:

LoadError: cannot load such file -- capistrano/rails
LoadError: cannot load such file -- capistrano/rails/assets

System configuration

$  cap development doctor
(Backtrace restricted to imported tasks)
cap aborted!
Don't know how to build task 'deploy:updated' (See the list of available tasks with `cap --tasks`)
Did you mean?  deploy:failed
/Volumes/Mo/r/sm/Capfile:4:in `<top (required)>'

Caused by:
LoadError: cannot load such file -- capistrano/rails
/Volumes/Mo/r/sm/Capfile:4:in `<top (required)>'
(See full trace by running task with --trace)

with --trace

LoadError: cannot load such file -- capistrano/rails
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Volumes/Mo/r/supermarket/Capfile:4:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:82:in `block in run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/capistrano-3.14.1/lib/capistrano/application.rb:14:in `run'
/Users/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/capistrano-3.14.1/bin/cap:3:in `<top (required)>'
/Users/deploy/.rbenv/versions/2.6.1/bin/cap:23:in `load'
/Users/deploy/.rbenv/versions/2.6.1/bin/cap:23:in `<main>'
mattbrictson commented 4 years ago

Does it work if you use bundle exec cap instead of just cap?

E.g.

bundle exec cap development deploy
dvodvo commented 4 years ago

Unfortunately not. Identical behaviour.

mattbrictson commented 4 years ago

Hmm. Based on this error message:

Don't know how to build task 'deploy:updated'

Perhaps that is an indication that your Capfile is not loading the standard deploy tasks? Your Capfile should look something like this:

require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

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

Could you post your full Capfile?

dvodvo commented 4 years ago

Right: the order matters. So I crossed my wires a while ago. The reason being I was getting errors are found a way to deploy by ignoring 'capistrano/rails'

Warning: the running version of Bundler (2.0.1) is older than the version that created the lockfile (2.1.4). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.

 DEBUG [b094a510]   Your Ruby version is 2.3.1, but your Gemfile specified 2.6.1

after having just executed 'gem install bundler' (returning 2.1.4) and

$ ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]

The capfile has:

require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

# require "capistrano/rails"
# previous line covers these default deployment tasks 
 require "capistrano/bundler"
 require "capistrano/rails/assets"
 require "capistrano/rails/migrations"
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

where I swapped, back and forth, the single 'catch-all' require for the three individual ones. Always same result -> Failures starts at asset deployment :

** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:

 DEBUG [ceabb5cf] Running [ -L /home/jerdvo/supermarket/releases/20200702032720/public/assets ] as jerdvo@138.68.104.77

 DEBUG [ceabb5cf] Command: [ -L /home/jerdvo/supermarket/releases/20200702032720/public/assets ]

This is consistent across 3 applications on 2 servers (Ubuntu 16.04 and 20.04)

mattbrictson commented 4 years ago

Looks like the LoadError that you originally reported is resolved, so I will close this issue.

Please open a separate issue with the new error that you are seeing. When you open the issue make sure it has detailed reproduction steps, the full output including error message and stack trace, as well as the output of cap doctor. That will help identify the bug. We use GitHub issues for bug reports, not as a general discussion forum or for user support. Thanks for your help!