1

Ok, following on from this question, I'm still having problems getting things working. I'm doing this:

if [ "$(id -nu)" != 'your_user' ]; then
  exec sudo -Hu 'your_user' $0
fi
which ruby
cd /path/to/my/app
rake db:backup

The problem is, which ruby is printing /usr/bin/ruby, but when I run it in a normal bash session I get /home/nick/.rvm/rubies/ruby-1.9.2-p136/bin/ruby, because I'm using RVM. So rake doesn't work because it's working from the wrong Ruby installation. Any ideas?

5

Looks like Florian sorted this on the linked question

sudo -u 'user_name' -i

"runs the given command in a login shell, i.e. you get the same environment as if you login in text mode."

  • -H is not needed as -i does that already. – Florian Diesch May 19 '11 at 15:49
  • @Florian - Thanks for the clarification. This is all just magic spells for me at the moment :P – Skilldrick May 19 '11 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.