13

I am trying to get Capistrano up and running for the first time in a rails app. I have a linux server running Ubuntu 12.04, nginx, unicorn and rails, however, I seem to be running into a few issues. I am also using Capistrano 3.0.0, rails 3.2.14, bundler 1.4.0 & ruby 1.9.3p448 using RVM.

I only have a production stage set up and at this point in time and I'm only concerned with Capistrano communicating with my server and pushing my code from github ( No migrations and bundling etc just yet).

When I try the command cap production deploy:check or cap production deploy:setup ( which seems to be deprecated?) with the setup below, I get the following error msg:

I'm not really sure where to start on this error, and google doesn't suggest much. I have tried adding the rvm-capistrano gem but to no avail. How can I amend my code to address this error?

    cap aborted!
undefined method `instance' for Capistrano::Configuration:Class
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.4.0.rc.1/lib/bundler/capistrano.rb:11:in `<top (required)>'
config/deploy.rb:1:in `<top (required)>'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/setup.rb:12:in `load'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/setup.rb:12:in `block (2 levels) in <top (required)>'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/lib/capistrano/application.rb:12:in `run'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-3.0.0/bin/cap:3:in `<top (required)>'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/bin/cap:23:in `load'
/Users/andrew/.rvm/gems/ruby-1.9.3-p448/bin/cap:23:in `<main>'
Tasks: TOP => production
(See full trace by running task with --trace)

deploy.rb

require "bundler/capistrano"

set :stages, %w(staging production)
set :default_stage, "production"

set :application, "my_app"
set :user, "andrew"
set :scm, "git"
set :repository, "https://github.com/my_repo/#{application}"
set :branch, "master"

set :deploy_to, "/home/rails/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false

default_run_options[:pty] = true
ssh_options[:forward_agent] = true

after "deploy", "deploy:cleanup" # keep only the last 5 releases

namespace :deploy do
  task :restart, roles: :app do
      run "touch #{current_path}tmp/restart.txt"
    end
  end
  after :finishing, 'deploy:cleanup'

deploy/production.rb

#Real IP ommitted 
server "10.2.32.68", :web, :app, :db, primary: true

Capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
# require 'capistrano/bundler'
# require 'capistrano/rails/assets'
# require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

EDIT After looking at the offending line in capistrano.rb within bundler it mentions to add require 'bundler/deployment' to deploy.rb, which has seemed to get rid of the capistrano instance error.

NOTE Downgraded to capistrano 2.15.5 which got rid of the errors.

3 Answers 3

21

First of all, there were a couple of changes made in capistrano 3. See the release notes : http://www.capistranorb.com/2013/06/01/release-announcement.html

Also go through the readme. https://github.com/capistrano/capistrano/blob/master/README.md

Capistrano 3 has moved out bundler integration into a gem.To solve your problem :

 1. Uncomment require 'capistrano/bundler' from capify. 
 2. add gem 'capistrano-bundler' to your gemfile.
 3. Go through the comments in capify file and uncomment whichever module you require.

Oh and if you don't wanna use bundler as of yet, remove the first line : require "bundler/capistrano". easy as that.

Also you can't use variables like the previous way now.Instead of directly reading it, use fetch(:application) to read a variable.

I would be easier for you to move back to capistrano v2.

2
  • I really don't think moving back to v2 is easier. First it's worth trying to start over with a cap install (though make back ups of your deploy.rb,production.rb and capifile files first!), then add pieces back in until it works. Also, I fixed this problem by using capistrano 3.1. I the issue on capistrano 3.3.5.
    – yekta
    Feb 23, 2015 at 15:06
  • @yekta the question was asked in 2013. Just when cap 3 was launched. At that point of time it would have been easier for him to move back to v2, since not much help was available. May 20, 2016 at 5:49
3

I suspect this problem is because Bundler 1.3.5 is not compatible with the latest version of Capistrano. Try upgrading to the Bundler pre-releases: gem install bundler --pre.


I noticed also that you're using a very old version of Rails 3.2, which is probably vulnerable to some security exploits. I would really strongly recommend upgrading that version of Rails to something more recent, like Rails 3.2.14.

2
  • I think you are right, this has also highlighted a few issues in my project. Upgrading to 3.2.14 as suggested, will try to re-capify when fully updated and get back to this. Oct 15, 2013 at 0:49
  • 1
    For what its worth upgrading did not resolve this issue for me. Nov 10, 2013 at 10:41
3

For Capistrano 3, they recommend using http://github.com/capistrano/bundler

Its mentioned here https://github.com/bundler/bundler/blob/master/lib/bundler/capistrano.rb

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.