2

Hi I'm trying to use the ruby net/ssh gem (2.0.24) to connect to a remote server and run a rake task. I can run other simple tasks using the script outlined below, but rake is failing.

This is my code

Net::SSH.start("myremote_server", 'ubuntu', :keys => ['abcdef.pem'], :paranoid => false, :verbose => :debug) do |ssh|
  result = ssh.exec!("cd a_rails_directory; rake sunspot:solr:start")
  puts result
  ssh.loop
end

and I get the following error message

rake aborted!
uninitialized constant Bundler
/home/ubuntu/a_rails_directory/config/boot.rb:9:in `rescue in <top (required)>'
/home/ubuntu/a_rails_directory/config/boot.rb:5:in `<top (required)>'
/home/ubuntu/a_rails_directory/config/application.rb:1:in `<top (required)>'
/home/ubuntu/a_rails_directory/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

I can run the rake taks quite easily when I ssh-into the remote server manually, but it doesn't work with net/ssh as I've outlined above.

Somehow, I feel like I'm not connecting with the proper shell or the proper access to the path variables, but I'm not sure and I don't know how to fix it either. Any thoughts?

TIA

1
  • Try bundle exec rake ... on your production env. Commented Jan 21, 2013 at 17:47

1 Answer 1

3

never mind. figured out how to load the relevant ruby path info

result = ssh.exec!("[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && source \"$HOME/.rvm/scripts/rvm\" ; cd rails_directory; rake sunspot:solr:start")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.