1

I have this command:

ubuntu@ip-10:~$ sudo su deploy -c 'rvm install 1.9.3' 
bash: rvm: command not found

I also tried:

ubuntu@ip-10:~$ sudo su deploy -c 'source /home/deploy/.bashrc && rvm install 1.9.3' 
bash: rvm: command not found

Same result. Not sure what's happening because when I do this:

sudo su deploy
deploy@ip-10-101-6-147:/home/ubuntu$ rvm install 1.9.3
Fetching yaml-0.1.4.tar.gz to /home/deploy/.rvm/archives

All works great. But I can't do that because this is for a shell script. Why doesn't it work in the first two instances?

1
  • what happens if you add dash after su? E.g.: sudo su - deploy -c 'rvm install 1.9.3'? It works?
    – kenorb
    Jul 31, 2012 at 22:44

2 Answers 2

1

I think when you use sudo, it creates a new sub-shell without all the env variables.

If I remember correctly, you have to use the command rvmsudo, in order for rvm to have the proper variables.

1
  • the sudo is not for the command...its for running the command as the deploy user Jul 30, 2012 at 22:27
0

Seems like you are trying to simply switch user and run a command that deploys some files in to that user's home.

su deploy -c 'rvm install 1.9.3'

You should not need to elevate privileges with sudo to run su, and if you need sudo to run rvm then you probably can do it with

su deploy -c 'sudo rvm install 1.9.3'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .