Capsitrano fails looking for ruby gems

I’m attempting to deploy my first RoR app using capistrano with a few gems (that Dreamhost doesn’t provide) in my own local directory.

Some things work, such as “cap deploy”. But “cap migrate” wants one of my local gems and can’t find it.

Here’s my ~/.bash_profile:
export GEM_HOME="$HOME/.gems"
export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8"
export PATH="$HOME/.gems/bin:$PATH"

and I have a .gemrc file, too.

When I ssh in and try “env” I get:

[washington:/home/fdmoves]$ env

Here’s where things get interesting.

When I try “cap shell” and “env” I don’t see the GEM_HOME and GEM_PATH environment variables.

$ cap shell
loading configuration /Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/capistrano-1.2.0/lib/capistrano/recipes/standard.rb
loading configuration ./config/deploy.rb

  • executing task shell
    cap> env
    [establishing connection(s) to]
    Password: ******

[] executing command
[] PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
command finished

It appears capistrano doesn’t have the same environment when it runs, so it doesn’t know the GEM_HOME and GEM_PATH.

So here’s my question. How do I force capistrano to pick up the shell environment variables when it runs? Why doesn’t it pick up the environment variables that are set in my ~/.bash_profile ?

Any suggestions will be most welcome!

– Daniel