How do you login into /bin/bash automatically?

12,818

Solution 1

  • 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 .

Solution 2

Solution which works for me is to add following line to your .bashrc file:

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

Solution 3

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:
12,818

Related videos on Youtube

Ordep81
Author by

Ordep81

Updated on September 18, 2022

Comments

  • Ordep81
    Ordep81 over 1 year

    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?

    • Johannes Kohnen
      Johannes Kohnen over 10 years
      Could you run echo $PATH; which ruby once before and once after running bash and show the output here?
    • jrg
      jrg over 10 years
      Are you using rvm?
    • Ordep81
      Ordep81 over 10 years
      This is the before : /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr‌​/sbin:/usr/bin:/sbin‌​:/bin:/usr/games:/ho‌​me/ordep/.rvm/bin /usr/bin/ruby
    • Ordep81
      Ordep81 over 10 years
      This is the after: /home/ordep/.rvm/gems/ruby-2.0.0-p0/bin:/home/ordep/.rvm/gem‌​s/ruby-2.0.0-p0@glob‌​al/bin:/home/ordep/.‌​rvm/rubies/ruby-2.0.‌​0-p0/bin:/home/ordep‌​/.rvm/bin:/usr/lib/l‌​ightdm/lightdm:/usr/‌​local/sbin:/usr/loca‌​l/bin:/usr/sbin:/usr‌​/bin:/sbin:/bin:/usr‌​/games /home/ordep/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
    • geirha
      geirha over 10 years
      Did you add something to ~/.bash_profile or ~/.profile when installing this ruby thing?
  • Ordep81
    Ordep81 over 10 years
    I'm using the default ubuntu terminal. How do I go about getting it to start in login shell?
  • Johannes Kohnen
    Johannes Kohnen over 10 years
    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.
  • Ordep81
    Ordep81 over 10 years
    I must ask how would go about fixing the initialization? Im a complete Linux noob.
  • Henning Kockerbeck
    Henning Kockerbeck over 10 years
    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.