RVM stuck installing Ruby

Scenario

The RVM tool has been installed according to the instructions on its website. All the required tools (e.g. gcc) and libraries (e.g. zlib) that are required to compile Ruby (and most gems) have been installed. The “rvm” command can be run from the command line.

The Issue

When attempting to install any version of Ruby (e.g. Ruby 1.8.7):

rvm install 1.8.7

The installation gets stuck on

ruby-1.8.7-p371 - #installing

Troubleshooting

After removing RVM (and the failed Ruby installs) using the implode command, I started fresh, attempting to install Ruby 1.8.7, this time with the trace flag enabled:

rvm --trace install 1.8.7

This revealed that rvm cycles through the $PATH variable looking for a path that matches the currently executing rvm’s base path.

In other words, the command:

rvm install 1.8.7

is looking through this:

$PATH=/home/edin/.rvm/bin/:${PATH}

looking for this:

/home/edin///.rvm/bin

when it should be looking for this:

/home/edin/.rvm/bin

The line that fails is below, and it is clear why it fails: a string comparison is being used to compare filesystem paths.

__rvm_string_match /home/edin///.rvm/bin /home/edin/.rvm/bin

The Fix

To fix this, I modified the rvm/bin path in the $PATH variable in my .bashrc and .bash_profile to contain less leading slashes.