Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Im on 12.04 LTS and am doing to Ruby on Rails development. When I start up my terminal and type in ruby -v it will list my Ruby as 1.8.7. When I type in /bin/bash --login then ruby -v will list it as 2.0.0 which is what I want in order to run rails 4.0. Problem is that I have to type in /bin/bash --login everytime I start up my terminal. Is there a way that I can log into /bin/bash automatically when I open up my terminal?

share|improve this question
    
Could you run echo $PATH; which ruby once before and once after running bash and show the output here? –  JoBo Sep 2 '13 at 22:59
    
Are you using rvm? –  jrg Sep 2 '13 at 23:21
    
This is the before : /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin‌​:/bin:/usr/games:/home/ordep/.rvm/bin /usr/bin/ruby –  Ordep81 Sep 3 '13 at 0:18
    
This is the after: /home/ordep/.rvm/gems/ruby-2.0.0-p0/bin:/home/ordep/.rvm/gems/ruby-2.0.0-p0@glob‌​al/bin:/home/ordep/.rvm/rubies/ruby-2.0.0-p0/bin:/home/ordep/.rvm/bin:/usr/lib/li‌​ghtdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/g‌​ames /home/ordep/.rvm/rubies/ruby-2.0.0-p0/bin/ruby –  Ordep81 Sep 3 '13 at 0:21
    
Did you add something to ~/.bash_profile or ~/.profile when installing this ruby thing? –  geirha Sep 3 '13 at 8:26
add comment

2 Answers

Technically, RVM is loaded into your shell session as a function. If you're using Bash as your shell, this integration is done by the config file .bash_profile. As you might know, there are different "types" of shell sessions, namely login shells, interactive shells and non-interactive shells. Depending on which of that your bash session is, different config files get involved. The .bash_profile config file, that handles the integration of RVM, is included with login shell sessions, but not with "merely" interactive or non-interactive shell sessions. For more details, you can read up in the RVM docs.

So you need to make sure that when you start up your terminal, the shell session is started as a login shell session. There probably is a setting with your terminal emulator for this. With the command /bin/bash --login that you used so far, you do nothing other than start another shell session inside your shell session, but this one as a login shell.

You probably have installed Ruby by the package manager (apt-get) in addition to installing it via RVM. So when RVM isn't integrated to your shell session, you're left with the "system Ruby". That's why you kind of "fall back" to Ruby 1.8.7.

share|improve this answer
    
I'm using the default ubuntu terminal. How do I go about getting it to start in login shell? –  Ordep81 Sep 3 '13 at 14:45
    
Terminal->Edit->Profiles->Default->Edit->Title and Command->Run command as login shell. But a more elegant approach would be to fix the initialization so that ruby is properly configured on any shell. –  JoBo Sep 3 '13 at 15:00
    
I must ask how would go about fixing the initialization? Im a complete Linux noob. –  Ordep81 Sep 3 '13 at 17:07
    
I'd recommend against "fixing" the initialization, because RVMs upgrade process only takes care of login shells. If you add your own initialization for non-login shells, you would have to maintain that yourself manually. If you want to do that, you can look for the line that the RVM install added to your ~/.bash_profile (should be the only line with respect to RVM) and copy it to ~/.profile. But in my opinion, just setting your terminal to start a login shell would be the preferred option. Almost all other terminal emulators do so by default, anyway. –  Henning Kockerbeck Sep 3 '13 at 18:46
add comment
  • Open the terminal
  • From menu-bar, select Edit > Profiles
  • In opened prompt Edit > Default
  • In Tab "Title & Commands" -> check "Run Command as Login Shell"
  • Restart Terminal

Now you need not to run /bin/bash --login again .

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.