views:

296

answers:

0

I'm having a problem with one of my Capistrano scripts - specifically, using using sudo, setting the path, and finding mongrel_rails. The path is correct, and mongrel_rails is in /opt/rails/gems/1.8/bin, but I getting the following error:

/usr/lib/ruby/1.8/rubygems.rb:578:in `report_activate_error': Could not find RubyGem mongrel (>= 0) (Gem::LoadError)

Here's a snippet of my Capistrano script:

GEM_HOME = "/opt/rails/gems/1.8"
MONGREL_PATH = "#{GEM_HOME}/bin/mongrel_rails"
<snip>
default_environment['GEM_HOME'] = GEM_HOME
default_environment['PATH'] = "#{GEM_HOME}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
<snip>
  desc "A task to test stopping mongrels."
  task :test_stop do
    #run "cd #{current_path}; ls -lt; env && #{sudo :as => 'rails'} mongrel_rails cluster_stop"
    #run "cd #{current_path}; ls -lt; env && #{sudo :as => 'rails'} #{MONGREL_PATH} cluster_stop"
    run "cd #{current_path}; ls -lt; env && #{sudo :as => 'rails'} /opt/rails/gems/1.8/bin/mongrel_rails cluster_stop"
  end
end

Here's the error:

*** [err :: yourmachine.com] /usr/lib/ruby/1.8/rubygems.rb:578:in
`report_activate_error': Could not find RubyGem mongrel (>= 0) (Gem::LoadError)

failed: "env GEM_HOME=/opt/rails/gems/1.8 
PATH=/opt/rails/gems/1.8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin sh -c 'cd /opt/rails/PsychApp/current; 
ls -lt; env && sudo -p '\\''sudo password: '\\'' -u rails /opt/rails/gems/1.8/bin/mongrel_rails cluster_stop'" on yourmachine.com

The output from 'ls' and 'env' give me what I'm looking for. I don't know enough about Unix users/groups/etc to say whether there is something I need to configure for the Rails user, or if I should call sudo differently..?