Topic: Capistrano Loading the real $PATH

Has anyone else seen this or is there something that I'm missing...

When I run cap deploy:migrate  I get this error:

  * executing "cd /var/www/vhosts/; rake RAILS_ENV=production  db:migrate"
    servers: [""]
    [] executing command
** [out ::] sh: rake: command not found
    command finished
command "cd /var/www/vhosts/; rake RAILS_ENV=production  db:migrate" failed on

When I ssh into the same account that capistrano is working in and run the same command, I'm successful.  So I think that is the environment:

I thought that it wasn't loading the profile, which included the rake path.  So changed the Capfile to forced a pty:

default_run_options[:pty] = true

With no change.

I tried to get it to stay in bash

default_run_options[:shell] = false

which only changed the error to
 ** [out ::] bash: rake: command not found

I specified the rake bin in deploy.rb
set :rake, "/usr/local/rubygems/gems/bin/rake"

Which did change the error message to
  * executing "cd /var/www/vhosts/; /usr/local/rubygems/gems/bin/rake RAILS_ENV=production  db:migrate"
    servers: [""]
    [] executing command
** [out ::] /usr/lib/ruby/site_ruby/1.8/rubygems.rb:578:in `report_activate_error'
** [out ::] :
** [out ::] Could not find RubyGem rake (>= 0)
** [out ::] (
** [out ::] Gem::LoadError
** [out ::] )
** [out ::] from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:134:in `activate'
** [out ::] from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:49:in `gem'
** [out ::] from /usr/local/rubygems/gems/bin/rake:18

I've run a hack to see what it thinks is the $PATH
  * executing "echo -e ${PATH//:/\\n}"
    servers: [""]
    [] executing command
** [out ::] /usr/local/binn/binn/usr/bin

which doesn't look normal at all...

I've even set up sshd_config to allow me to set the path in .ssh/environment but that still left me with the error above.

how can I get this back to the right PATH... is that my problem?

Any help would be great -- thanks


Re: Capistrano Loading the real $PATH

Sorry to resurrect a post from two years ago, but I just ran in to the exact same issue.

I called my hosting company with the error message (sh: rake: command not found), they said "Oh, yeah, right ... hang on", changed some server-side environment variable and voilà, the problem was solved.

I know this doesn't help you much, but it might point anyone else having this problem in the right direction.

Last edited by Jack Zelig (2011-02-24 16:20:03)