Fix RVM “run script from the internet to install”

On Wednesday I complained about the latest UN*X fad of installing software by running scripts from the internet, without any regard to how your operating system handles software installation.

Docker, that I complained about last time, at least has a script that takes into account the local software management solution (uses apt for Ubuntu, yum for Fedora, etc), but RVM – the Ruby Version Manager which is a popular tool among rubyists everywhere, just downloads a bunch of executable stuff (granted, most of it are scripts, but the difference is lost on most people) into arbitrary location on your file system. At least it doesn’t install system software, oh wait – it does.

While I can’t help with RVM’s desire to install system level software (that it actually needs because one of the things you want RVM to do for you is to compile ruby versions from source), I can try to help you figure out how to install RVM where you want it and use it how you want it.

I’m tackling two issues here:

  1. Where to install RVM – normally this is ~/.rvm, but you may want to specify that yourself
  2. Prevent the automatic loading of the RVM shell extensions into the shell and let you control that

The main reason this is interesting for me is that I need to be able to set RVM up in a local directory on a CI system without affecting other projects running on the same system account.

Other issues that we may also want to have control of in the future are:

  • Installation of additional system software to support building ruby from source
  • Select the RVM version to install, download and install it manually (the setup below lets the internet installer do that)


We start by downloading the install from the RVM website, similar to how the website instructs you to, but we aren’t going to just feed it into the shell – we’ll just save it:

curl -o rvm-installer

Now we are going to run it without worrying too much 😉1

bash rvm-installer stable --ignore-dotfiles --path where/to/install

The --ignore-dotfiles switch is to tell RVM to keep its dirty paws off of our precious shell configuration files, and --path is used to select where we want RVM to install itself. Under that directory it will also create the folder where it will download and build all its ruby binaries – so its pretty self-contained, but you want to make sure there is enough space there: an RVM setup can quickly grow to 500 MB or more. I usually install such things to ~/.local/rvm or maybe ~/.local/share/rvm though the longer the path, the more you’d need to type when you want to use it…

After the RVM installer has done its thing, you can choose when to load it into your shell to engage in your RVM habit – whenever you start a new shell that you want to be “RVM enabled”, import the RVM shell extension from the RVM scripts directory. For example, if I installed RVM under ~/.local/rvm, I’d run:

source ~/.local/rvm/scripts/rvm

You can also use RVM with almost all the functionality by using the RVM command as a normal command (without the shell extension). If you have that behavior in mind, then I recommend symlinking the RVM executable to your local bin directory (this is ~/bin by default, but I like to move it to ~/.local/bin as it makes more sense to me. The example above assumes that you did as well):

ln -s ~/.local/rvm/bin/rvm ~/.local/bin/rvm

After you do that, you can just run rvm whenever you want to use it. Do remember that without the shell extension loaded, RVM can’t take over the commands ruby, gem and friends, so if you want to run commands on the RVM managed ruby, you need to run something like rvm <version> do gem.

  1. OK, that’s kind of hypocritical – we should read the source and understand what it is doing before unleashing it on our unsuspecting home directory, but this is the “TODO” above. Also the RVM shell code is really hard to read… []

3 Responses to “Fix RVM “run script from the internet to install””

  1. Amir:
    Fatal error: Uncaught Error: Call to undefined function comment_dir() in /vhosts/coil/geek/public_html/wp-content/themes/modern-bluish/single-comment2.php:17 Stack trace: #0 /vhosts/coil/geek/public_html/wp-content/themes/modern-bluish/functions.php(8): include() #1 /vhosts/coil/geek/public_html/wp-includes/class-walker-comment.php(179): themed_comment() #2 /vhosts/coil/geek/public_html/wp-includes/class-wp-walker.php(144): Walker_Comment->start_el() #3 /vhosts/coil/geek/public_html/wp-includes/class-walker-comment.php(139): Walker->display_element() #4 /vhosts/coil/geek/public_html/wp-includes/class-wp-walker.php(387): Walker_Comment->display_element() #5 /vhosts/coil/geek/public_html/wp-includes/comment-template.php(2229): Walker->paged_walk() #6 /vhosts/coil/geek/public_html/wp-content/themes/modern-bluish/comments.php(26): wp_list_comments() #7 /vhosts/coil/geek/public_html/wp-includes/comment-template.php(1539): require('/vhosts/coil/ge...') #8 /vhosts/coil/geek/public_html/wp-content/themes/modern-bluish/single.php( in /vhosts/coil/geek/public_html/wp-content/themes/modern-bluish/single-comment2.php on line 17