Rails 3 -- Bundler/Capistrano Errors Rails 3 -- Bundler/Capistrano Errors ruby-on-rails ruby-on-rails

Rails 3 -- Bundler/Capistrano Errors


UPDATE:

For RVM >= 1.11.3, you should now just use the rvm-capistrano gem. For older RVM >= 1.0.1, the answer below still applies.


ORIGINAL ANSWER:

Okay, though I still haven't gotten a full cap deploy to work, I did fix this problem. The problem was Capistrano trying to use a different path for Bundler (and other gems) than the RVM paths.

Check your Capistrano path by doing cap shell, then echo $PATH. You'll probably see your standard /usr/local/bin and /usr/bin, but that's not where RVM has Bundler, et al., stored.

Edit your Capistrano config/deploy.rb file, and add the following lines, per these instructions:

# Add RVM's lib directory to the load path.$:.unshift(File.expand_path('./lib', ENV['rvm_path']))# Load RVM's capistrano plugin.    require "rvm/capistrano"set :rvm_ruby_string, '1.9.2'set :rvm_type, :user  # Don't use system-wide RVM

That finally got Capistrano to see Bundler and start loading gems appropriately.


Bundler isn't found because .bash_profile is not being loaded and thus your PATH is wrong. This is probably because you have the RVM script in .bash_profile.

The simple answer is to move the RVM script from .bash_profile to .bashrc and Capistrano should be able to find it (also verify that .bash_profile sources .bashrc).

Capistrano uses SSH to execute commands on the server via a non-interactive shell. This shell session will source .bashrc but not .bash_profile. I added an ECHO statement to both and ran an LS via SSH. You can see in the results below that only .bashrc is sourced:

$ ssh user@123.amazonaws.com ls.bashrc loadedgitfile1file2


I had an identical problem using rbenv. The solution was to take the rbenv specific lines from the bottom of my .bashrc file and put them at the top. The first line of my .bashrc file was returning aborting if the shell wasn't running in interactive mode.