A collection of computer systems and programming tips that you may find useful.
 
Brought to you by Craic Computing LLC, a bioinformatics consulting company.

Tuesday, January 4, 2011

rvm and shell scripts

If you want to use a specific version of Ruby via RVM inside a shell script then you need to make sure that the environment is setup correctly.

The RVM site addresses that HERE for the case where RVM is installed in a user's home directory.

But on my server I have a system-wide installation. In that case you should have a /etc/rvmrc file with a default setup and you need to source this.

Your scripts should look something like this:
#!/bin/bash                                                                                                                                                 
source "/etc/rvmrc"

rvm use 1.9.2

# mycommands_go_here