Take the 2-minute tour ×

I am new to Jenkins CI. I'm install RVM in my remote Jenkins and when I execute below shell.

#!/bin/bash -x
source ~/.bashrc
rvm use 1.9.3@rails-3.2.3

I get following errors.

+ source /var/lib/jenkins/.bashrc
++ PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/var/lib/jenkins/.rvm/bin:/var/lib/jenkins/.rvm/bin
+ rvm use 1.9.3@rails-3.2.3

You need to change your terminal settings to allow shell login.
Please visit https://rvm.io/workflow/screen/ for example.

What does it mean? I don't have any idea. Please help me.

UPDATED: I'm tried below script but I still get errors:

#!/bin/bash -x
source /home/zeck/.bashrc
[[ -s ".rvmrc" ]] && source .rvmrc
export RAILS_ENV=test
bundle install


/tmp/hudson457106939700368111.sh: line 5: bundle: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Jenkins build shell can't detect RVM, gemsets and gems. What should I do?

UPDATED 2: Therefore jenkins can't detect ruby.

+ ruby -v
/tmp/hudson2505951775163045158.sh: line 5: ruby: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILUR

I'm not using any jenkins plugn and I'm just run script from Build->Execute shell section.

share|improve this question
add comment

4 Answers

up vote 5 down vote accepted


source $(rvm env 1.9.3@rails-3.2.3 --path)

make sure you run the stable RVM:

rvm get stable
share|improve this answer
Very first thank you for trying to help. But I get 'rvm: command not found'. Please see my updates –  Zeck Apr 18 '12 at 14:19
it's because you use different users for one rvm installation, make sure the second user zeck uses the same RVM - in /home/zeck/.bashrc add: export PATH=$PATH:/var/lib/jenkins/.rvm/bin –  mpapis Apr 18 '12 at 15:13
add comment

As the error message suggests, RVM expects an login shell. Changing the hashbang line to #!/bin/bash -xl should resolve this.

share|improve this answer
By the way, sourcing .rvmrc can print a lot to the terminal. You may want to instead use a #!/bin/bash -l, then do set -x after sourcing .rvmrc. –  disrupt May 9 '12 at 15:40
add comment

Yes, apparently you miss the $HOME/.rvm/bin in your PATH. I am using rvm successfully from Hudson on Mac OS X. First thing to notice is that, unless you define BASH_ENV environment variable (ENV for sh), .bashrc is called automatically only with interactive non-login shell. Such a shell is started when you do - for example - the following from the command line:

$ /bin/bash

When you use #!/bin/bash in your script, .bashrc will not be called.

To make rvm work with Hudson, I have the following in my .bash_profile:

export PATH


Thanks to [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" I have rvm enabled every time I start new terminal window (interactive, login shell).

I do not put anything in my .bashrc, especially I am not sourcing rvm scripts there. Nothing wrong with that, but if any other scripts makes something stupid like setting `export BASH_ENV=$HOME/.bashrc' and then invoke non-interactive shell, you see what may happen - it is actually easy to forget.

Therefore, instead of loading things to your .bashrc, it is better to keep your script independent from any shell startup file and make sure that the correct environment is set up within the script. I still keep $HOME/.rvm/bin in my .bash_profile, but then I include the following at the beginning of my script:



rvm use 1.9.3-head@MyGemSet

set -ex
cucumber # just an example

Notice the -e option which forces the script to exit with error code if any command following set -ex fails. This is behavior you may want when using the script with Hudson. It is incorrect to say that RVM expects a login shell. Although using #!/bin/bash -l in your script will work, it does not seem like the best approach.

share|improve this answer
Yes, this helped. The location of RVM may differ, in my case it was [[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm" which worked, together with rvm use ruby_name@gemset_name –  0x4a6f4672 Nov 21 '12 at 11:42
add comment

adding a shebang to the build commands in jenkins fixed this for me

    #!/usr/bin/env bash

    rvm use 2.0.0
    bundle install
    rake test
share|improve this answer
You sir, made my day :) –  ncuesta Oct 31 '13 at 19:50
add comment

Your Answer


