Yes, if gnome terminal is configured to start bash as login shell then bash will not read .bashrc
The behaviour, in short, is as follows:
- bash started as an interactive login shell: it reads
.profile but not .bashrc
- bash started as an interactive non-login shell: it reads
.bashrc but not .profile
(there are more peculiarities about this elaborated below)
There is certainly some rationale behind this design decision which made sense at some time in the past. But now it is just an annoying legacy which confuses newcomers.
Some explanation of the terminology:
- An interactive shell is a shell with which you can interact. That means you can type commands in it.
- A non-interactive shell is a shell with which you cannot interact. Shell scripts run in non-interactive shells.
- A login shell is the shell which is started when you login to your system.
- A non-login shell is a shell which is started after the login process.
Typically when you work in gnome-terminal you work with bash as a interactive non-login shell. Interactive because you type commands in it. Non-login because you did not login with the shell (gnome is the "login shell" in this case).
Apart from the configuration files loaded during startup there is not much difference between a login shell and a non-login shell.
More background:
There is some confusion in the internet about where to put configuration. Some say .bashrc but as you experienced .bashrc is not always loaded. Some say .profile which is a bit more correct. But it also has caveats. One is that .profile is typically only read by login shells. Another is that .profile is read by more programs than just bash. So one must take care to not put bash specific things in .profile.
Ideally we put in .bashrc only settings relating to the bash shell itself. And in .profile put environment variables not bash related. But this is often mixed up due to a variety or reasons. Some of them are:
- bash settings typically work well if put in
.profile. This is because .profile, if it is read, is typically read by bash.
- environment variables that are not bash related work well in
.bashrc. Because bash does not care about those but they are set so they work.
- newcomers often can't tell which setting is bash related and which is not.
To add to this confusion gnome-terminal can be set to login shell which changes behaviour intransparently.
There are also some questionable "fixes" or workarounds to this problem. Debian (and ubuntu) for example has a default .profile set up to read .bashrc. In effect both .profile and .bashrc are read on login shells. But just .bashrc on non login shells. This in turn caused many to learn to put everything in .bashrc because it is always loaded.
I find this questionable because .profile is not a bash exklusive configuration file. It is global configuration file read by many programs. So it should not load .bashrc. (i know it loads .bashrc conditionaly but still why should other programs even have to decide whether to load .bashrc or not)
Here is how i recommend to set up your configuration files to be less confusing.
Create a ~/.bash_profile file and put the following lines (and only these lines):
[ -f "$HOME/.profile" ] && source "$HOME/.profile"
[ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc"
The deal with .bash_profile is that it is the first file bash will look for. If it exists it will no longer look for .profile.
Now if bash is started as an interactive login shell it will read the following files:
.bash_profile
.profile
.bashrc
and if bash is started as an interactive non-login shell:
.bashrc
You see that .bashrc is always read. And .profile is read additionally if it is a login shell.
And all other programs which want to just read .profile can do so without having .bashrc mixed in.
Now put bash specific settings .bashrc. All the rest in .profile. For example PS1 and HISTCONTROL goes in .bashrc while PATH and LC_ALL goes in .profile
Your RVM variable should go in .profile. It will take effect after a logout and login.
more information
http://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files
https://www.baeldung.com/linux/interactive-non-interactive-login-non-login-shells
https://www.baeldung.com/linux/bashrc-vs-bash-profile-vs-profile
https://unix.stackexchange.com/questions/170493/login-non-login-and-interactive-non-interactive-shells
https://unix.stackexchange.com/questions/38175/difference-between-login-shell-and-non-login-shell
Differentiate Interactive login and non-interactive non-login shell
note that some texts above say some things which contradict what i wrote above. in all cases i am of the opinion that my opinion is the more correct one.
~/.bashrcin the first place, in the profile instead. The fault is on rvm. – geirha Jul 25 '12 at 07:56~/.profile– sanmai Apr 28 '16 at 00:59.bashrcrelative to what it needs to do. If the interactive shell always read.bashrcshould that be before or after.profile? What if you want to set up some things in.bashrcwhich.profiletakes for granted? And at the same time you want some things in.bashrcto rely on something set up by.profile? Neither loading order will satisfy both scenarios. – Kaz Aug 04 '17 at 08:15