Sunday, February 17, 2013

Managing the the rvm-capistrano gem

Capistrano's a fantastic gem. Add it to your Rails app, spend only a very few short hours fiddling with the config settings in desperation, trying to get the damn thing working (github.com/capistrano/capistrano/wiki/2.x-From-The-Beginning saved me so so much time - don't worry about it mentioning Rails 2.x apps, the instructions work just fine for Rails 3.x apps too), and you can upload your development code to a production server and make it available to your baying masses of fans.

Just recently, though, I tried uploading my latest code update to PathWrangler, typed 'cap deploy' on the command line, and this got spat back at me:


/Users/[me]/.rvm/lib/rvm/capistrano.rb:5 in `<top (required)>': RVM - Capistrano integration
was extracted to a separate gem, install `gem install rvm-capistrano` and remove the
`$LOAD_PATH.unshift` line, note also the 'set :rvm_type, :user' is now the default (instead
of :system). (RuntimeError)


And following that, a lovely stack trace. Groovy.

A quick bit of Googling reveals this - Ruby Version Manager's discussion on how the integration of RVM functionality into Capistrano has now been moved into its own, separate gem, called 'rvm-capistrano'. Okay, fair enough I think to myself - I shall add that to my Gemfile, and try 'cap deploy' again.

Result:

/Users/[me]/.rvm/lib/rvm/capistrano.rb:5 in `<top (required)>': RVM - Capistrano integration
was extracted to a separate gem, install `gem install rvm-capistrano` and remove the
`$LOAD_PATH.unshift` line, note also the 'set :rvm_type, :user' is now the default (instead
of :system). (RuntimeError)


The same error again. Huh?

A bit of fiddling around reveals the problem - in my config/deploy.rb file, the hub of all Capistrano activity in a Rails app, you of course have 'require "rvm/capistrano"', to import RVM's Capistrano functionality. When the command-line error message says "remove the `$LOAD_PATH.unshift` line", it's trying to tell you that because the RVM-Capistrano stuff is now in its own gem, you no longer need to write 'require "rvm/capistrano". Delete it, and all will be well.

2 comments:

  1. Thanks so much! I've been having the same problem and you led me down the golden path. Whew!

    ReplyDelete