Ruby on Rails Install with “Bad Interpreter” Errors

Today I decided to finally upgrade my Ruby on Rails setup at home. But upon running the rails -v command, I ran into this error:

bash: /opt/local/bin/rails: /opt/local/bin/ruby: bad interpreter: No such file or directory

Turns out for some reason there’s another (non-working) copy of rails in my /opt/local/bin/ directory. To fix the problem, I simply had to remove it (along with rake and other related executables out of there).

On a related note, I also tried upgrading rvm. But while trying to upgrade Ruby to the latest 1.9.3 with it using the rvm install 1.9.3, I kept getting this error:

curl: (7) couldn't connect to host

Finally, what worked was this:

curl -L get.rvm.io | bash -s stable --ruby

And to bind that to rails, similarly, do this:

curl -L get.rvm.io | bash -s stable --rails

That’s it.

Happy hacking.

References:
* Installing RVM
* RVM Repo