1

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.

  • 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 07 '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 07 '12 at 15:56
  • Coould you please add the result of type rvm and ls -l $(which rvm) please? – rahmu Nov 07 '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 07 '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 07 '12 at 16:59

3 Answers3

2

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?

0

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.

qqx
  • 2,588
  • 1
  • 19
  • 16
0

I have just added

#!/bin/bash --login 

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

manatwork
  • 31,277