Ask A Question

Notifications

You’re not receiving notifications from this thread.

Got error message when I install Capistrano, stuck at deployment for two days.

xiazhaoyang asked in Servers

I spent 2 days followed "Deploy Ruby On Rails onUbuntu 18.04 Bionic Beaver" , tried to deploy my rails project, now i'm out of my mind! I have repeated whole process for more than 4 times, always got problem at "Capistrano Setup" section, I ran cap production deploy, got the error below:

(Backtrace restricted to imported tasks)
cap aborted!
NoMethodError: undefined method `stages' for Capistrano::DSL:Module

Anyone know what happend?

Thanks

Sam

Reply

Hey Sam,

I'm assuming you've already went and re-run cap install to regenerate your configs.

Can you post more of the stacktrace? Just seeing the error alone isn't that helpful. It's more useful to see where in the code the error happened so you can look it up in the Capistrano repo and see what it wants so you can figure out what you did wrong.

I'll be curious to see where it happened. It might just be a typo in the config or something changed in a newer Capistrano.

Reply

Hi Chris,

Thank you for your reply, I found a potential problem, the ruby version on my Mac is 2.5.1, the Ruby 2.5.3 was installed on my server, did this cause the problem?

Thanks

Sam

Reply

Nope, minor version changes are only bug and security fixes. That error comes from Capistrano, not Ruby.

Reply
cap aborted!
NoMethodError: undefined method `stages' for Capistrano::DSL:Module
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-bundler-1.4.0/lib/capistrano/tasks/bundler.cap:69:in `<top (required)>'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-bundler-1.4.0/lib/capistrano/bundler/tasks.rb:1:in `load'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-bundler-1.4.0/lib/capistrano/bundler/tasks.rb:1:in `<top (required)>'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-bundler-1.4.0/lib/capistrano/bundler.rb:1:in `require_relative'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-bundler-1.4.0/lib/capistrano/bundler.rb:1:in `<top (required)>'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-rails-1.4.0/lib/capistrano/rails.rb:1:in `<top (required)>'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
/Users/sammbr/code/xiazhaoyang/deploybwg/Capfile:1:in `<top (required)>'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/rake_module.rb:29:in `load'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:82:in `block in run'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:80:in `run'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-3.11.0/lib/capistrano/application.rb:14:in `run'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-3.11.0/bin/cap:3:in `<top (required)>'
/Users/sammbr/.rbenv/versions/2.5.1/bin/cap:23:in `load'
/Users/sammbr/.rbenv/versions/2.5.1/bin/cap:23:in `<main>'

Caused by:
LoadError: cannot load such file -- capistrano/rails
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/sammbr/code/xiazhaoyang/deploybwg/Capfile:1:in `<top (required)>'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/rake_module.rb:29:in `load'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:82:in `block in run'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.1/lib/rake/application.rb:80:in `run'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-3.11.0/lib/capistrano/application.rb:14:in `run'
/Users/sammbr/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/capistrano-3.11.0/bin/cap:3:in `<top (required)>'
/Users/sammbr/.rbenv/versions/2.5.1/bin/cap:23:in `load'
/Users/sammbr/.rbenv/versions/2.5.1/bin/cap:23:in `<main>'
Reply

The website stop me from submitting the error message, for security?

Reply

Yeah, spam check. Code looks suspicious. :) I'll unmark them as spam.

Reply

Interesting to see "LoadError: cannot load such file -- capistrano/rails"

Do you have the capistrano-rails gem in your Gemfile?

I currently have this:

group :development do
  gem 'capistrano', '~> 3.11.0'
  gem 'capistrano-passenger', '~> 0.2.0'
  gem 'capistrano-rails', '~> 1.2'
  gem 'capistrano-rbenv', '~> 2.1'
end

And my Capfile looks like:

# Load DSL and set up stages
require "capistrano/setup"

# Include default deployment tasks
require "capistrano/deploy"

# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
# install_plugin Capistrano::SCM::Hg
# or
# require "capistrano/scm/svn"
# install_plugin Capistrano::SCM::Svn
# or
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#   https://github.com/capistrano/passenger
#
# require "capistrano/rvm"
# require "capistrano/rbenv"
# require "capistrano/chruby"
# require "capistrano/bundler"
# require "capistrano/rails/assets"
# require "capistrano/rails/migrations"
# require "capistrano/passenger"

require 'capistrano/rails'
require 'capistrano/passenger'
require 'capistrano/rbenv'
require 'whenever/capistrano'

set :rbenv_type, :user
set :rbenv_ruby, '2.5.3'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
Reply

Exactly the same as you except "require 'whenever/capistrano" , I didn't have this line in my file.

Reply

I'm confused by this line : linked file /home/deploy/build.gorails.com/shared/config/database.yml does not exist on IP_ADDRESS in your tutorial. Should I run on my server or local for this line?

Reply

The whenever line is only needed if you're using whenever.

The second is just an example error message of what happens when you haven't created the database.yml file on your server yet. You should see a similar error.

Reply

I think you should comment that line, beginner like me sometimes will confuse about the same style between command and comment ( or output ).

Reply

Agreed, I can definitely see the confusion.

Reply

I will try to deploy my app again tomorrow, hope I can make it~~

Reply

Let me know how it goes. You're pretty close. The first few times are always a huge pain with Capistrano.

Reply

Hi Chris

In your video, I didn't see you mention about the ideal ruby version and rails version for local computer, should they has the similar version as the server's? Is there anything I should pay attention to?

Thanks

Sam

Reply

You're right. Ideally you want the same version in both places that way what you run in development you know will work in production.

Reply

when I ran

git mv config/secrets.yml config/secrets.yml.example
git mv config/database.yml config/database.yml.example
git commit -m "Only store example secrets and database configs
cp config/secrets.yml.example config/secrets.yml
cp config/database.yml.example config/database.ym

i got:

fatal: bad source, source=config/secrets.yml, destination=config/secrets.yml.example
fatal: not under version control, source=config/database.yml, destination=config/database.yml.example
cp: config/secrets.yml.example: No such file or directory
Reply

I use Rails 5.2.1.1, is it a good version for deployment?

Reply

I have fixed the problems, it was because Rails 5.2.1.1 was not compatible with Capistrano 3.0. It workd after I downgraded the Rails 5.2.1.1 to Rails 5.2.0.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.