Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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."

share|improve this answer
    
-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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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