How do you login into /bin/bash automatically?
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.
Related videos on Youtube
Ordep81
Updated on September 18, 2022Comments
-
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
thenruby -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 over 10 yearsCould you run
echo $PATH; which ruby
once before and once after runningbash
and show the output here? -
jrg over 10 yearsAre you using rvm?
-
Ordep81 over 10 yearsThis 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 over 10 yearsThis is the after: /home/ordep/.rvm/gems/ruby-2.0.0-p0/bin:/home/ordep/.rvm/gems/ruby-2.0.0-p0@global/bin:/home/ordep/.rvm/rubies/ruby-2.0.0-p0/bin:/home/ordep/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games /home/ordep/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
-
geirha over 10 yearsDid you add something to
~/.bash_profile
or~/.profile
when installing this ruby thing?
-
-
Ordep81 over 10 yearsI'm using the default ubuntu terminal. How do I go about getting it to start in login shell?
-
Johannes Kohnen over 10 yearsTerminal->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 over 10 yearsI must ask how would go about fixing the initialization? Im a complete Linux noob.
-
Henning Kockerbeck over 10 yearsI'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.