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/example.org/apps/progdbapp/releases/20080804083156; rake RAILS_ENV=production  db:migrate"
    servers: ["example.org"]
    [example.org] executing command
** [out :: example.org] sh: rake: command not found
    command finished
command "cd /var/www/vhosts/example.org/apps/progdbapp/releases/20080804083156; rake RAILS_ENV=production  db:migrate" failed on example.org

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 :: example.org] 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/example.org/apps/progdbapp/releases/20080804082755; /usr/local/rubygems/gems/bin/rake RAILS_ENV=production  db:migrate"
    servers: ["example.org"]
    [example.org] executing command
** [out :: example.org] /usr/lib/ruby/site_ruby/1.8/rubygems.rb:578:in `report_activate_error'
** [out :: example.org] :
** [out :: example.org] Could not find RubyGem rake (>= 0)
** [out :: example.org] (
** [out :: example.org] Gem::LoadError
** [out :: example.org] )
** [out :: example.org] from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:134:in `activate'
** [out :: example.org] from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:49:in `gem'
** [out :: example.org] 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: ["example.org"]
    [example.org] executing command
** [out :: example.org] /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

Matt

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)