Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What am I missing? I can call "rvm" from the command line but not reference the entire path that which rvm says I'm using.

Not that it's important, but I stay logged in as "jenkins" the entire time and these commands are executed in succession.

$ whoami
jenkins

RVM is located here

$ which rvm
/home/jenkins/.rvm/bin/rvm

This works

$ rvm use 1.8.7
Using /home/jenkins/.rvm/gems/ruby-1.8.7-p370
Running /home/jenkins/.rvm/hooks/after_use

But this doesn't work

$ /home/jenkins/.rvm/bin/rvm use 1.8.7
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal settings to allow shell login.
Please visit https://rvm.io/workflow/screen/ for example.

Yes, I have visited the link that is referenced but I don't see how it applies to me.

share|improve this question
3  
Try type rvm and see what it tells you. It's likely that you aren't supposed to invoke ~/.rvm/bin/rvm directly, and that rvm is actually something else. –  jw013 Nov 7 '12 at 15:43
    
Ah...just thinking out loud...So, rvm is a function is telling me that when I call rvm, it's calling the function, passing arguments if applicable, etc., but I can't "execute" the file because it's not a program, it's just the function rvm and that function is pulled into my interactive session because of the following lines in my ~/.bash_profile: [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function source ~/.rvm/scripts/rvm Makes sense now! Thanks! –  harperville Nov 7 '12 at 15:56
    
Coould you please add the result of type rvm and ls -l $(which rvm) please? –  rahmu Nov 7 '12 at 16:39
    
@rahmu It seems that rvm is a shell function defined in ~/.rvm/scripts/rvm. See comment above by OP. –  jw013 Nov 7 '12 at 16:47
    
rvm is a function Then, <...>(displays content of ~/.rvm/scripts/rvm<...> -rwxrwxr-x 1 jenkins jenkins 1274 2012-09-14 16:28 /home/jenkins/.rvm/bin/rvm –  harperville Nov 7 '12 at 16:59

3 Answers 3

which rvm looks for an executable called rvm. That executable only outputs the “RVM is not a function …” message when run.

rvm is probably a function, or perhaps an alias, in your shell. It has been defined in your ~/.bashrc (or in the system-wide /etc/bash.bashrc or in a file included from one of these). To see what the rvm command is, run type rvm or command -v rvm.

See also How to use which on an aliased command?

share|improve this answer

rvm use works by modifying environment variables to indicate which version of ruby should be used. This can only be done if it is run as a function. If you run it as a command, either by using the full path or not having the function defined, that can't work. This is because if run as a separate process that process gets its own copy of the environment, that copy gets modified but is immediately lost when the process exits.

share|improve this answer

I have just added

#!/bin/bash --login 

in the beginning of the script in my Hudson job. Everything works now! :)

share|improve this answer

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.