4

I used to work with Ruby version 1.9.3 on Ubuntu and made an update that probably screwed my bash profile and I need help to turn it back rather than using version 1.8.7. Right now rails s opens the server with Ruby 1.8.7 and I get errors because of the newer syntax I use in my app.

.bash_profile:

cat ~/.bash_profile

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

which rails:

/usr/local/bin/rails

which ruby:

/usr/bin/ruby

ruby -v:

ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]

rvm list:

rvm rubies

=* ruby-1.9.3-p194 [ i686 ]

# => - current
# =* - current && default
#  * - default

rvm use 1.9.3:

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 https://rvm.io/integration/gnome-terminal/ for a example.
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Tom
  • 9,275
  • 25
  • 89
  • 147
  • [See this answer](http://stackoverflow.com/questions/8663936/how-do-i-change-my-ruby-version-using-rvm) – mabako Nov 05 '12 at 20:14
  • thanks @mabako i already looked at it and several more. It's a different situation – Tom Nov 05 '12 at 20:18

1 Answers1

15

You are not in the login shell. To enter the login shell try this command:

/bin/bash --login

After that you will be able to use RVM to select Ruby.

Also, there is permanent way, that you won't have to write this line everytime you open your terminal. Try this:

Edit menu -> Profile Preferences 

A dialog will appear, now select Run command in login shell.

After that, whenever you open your terminal, you will enter into the login shell, and you will be able to use RVM.

There is another way, you can write /bin/bash --login in your .bash_profile which will load every time when you reboot.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Akshay Vishnoi
  • 1,252
  • 12
  • 15
  • The profile preferences were correct and 'Run command in login shell' was selected because i did that before – Tom Nov 05 '12 at 20:28
  • Didn't this work for you? Actually i got same error, and got resolved with this. Now rvm is running fine. – Akshay Vishnoi Nov 05 '12 at 20:33
  • 1
    "/bin/bash --login in your .bash_profile" -- I don't think this would work, since .bash_profile only runs when you are in a login shell... Plus, it would make an infinite loop of starting bash when you do launch a login shell! – XP84 Nov 29 '12 at 18:44