Super Spread Sheet S³

Or little computing tricks and hacks

rvm and the gnome-terminal

I’m in a new project: learning Ruby and Ruby on Rails. Ruby is a very pretty language. I highly recommend the codeacademy tutorials.

For Rails I started the book by Michael Hartl. I am now just installing Rails and there is a lot I have to go through.

I’m explaining here a problem I came across after installation when running the rvm. Actually when changing terminals. All of a sudden I could not even run Rails, even though I had already ran the server. (I had decided that the location of my first_app was not satisfactory when I was about to create a repository in GitHub.) The explanations of the topic are around this section.

When attempting to run
rvm use 2.0.0@railstutorial_rails_4_0 --default

the following scary message was displayed:

RVM is not a function, selecting rubies with ‘rvm use …’ will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash –login` as the command.
Please visit for a example.

Luckily that link had the answer: when the gnome-terminal is not run as a login shell, not all of the right bash files are sourced. In that site, it is very well explained how to add the Run command as login shell to the Profile Preferences of the gnome terminal profile in use. (Full answer is here.)

The explanation of the problem is as follows:

  1. When you login graphically to your system it will read ~/.profile so you put there settings like LANG which are important for graphical applications
  2. When you open a terminal (except Gnome-terminal & Screen) you open a login shell which sources ~/.bash_profile
  3. When you execute commands in non login shell, it will execute ~/.bashrc

Some discussion on why it should (or not) be a login shell is found here and here.

Added note 26 August 2013

I have decided to go back to the default setting: opening a gnome-terminal as a non-login shell. If I need to run rvm in a particular terminal, I’ll just open a new session in the terminal as follows:
bash -l

Added note 30 August 2013

Running bash -l was not enough, althugh necessary.

The best solution is to include a .rvmrc file a the root of the application with a line indicating the gemset in use for that app:
rvm gemset_name


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: