For 11.04, I did a fresh install of my system. Part of that install was to install rvm, which sticks a rvm.sh
in /etc/profile.d/
. This doesn't work as /etc/profile
(which loads each +r in /etc/profile.d/*.sh
) is not being loaded. According to the documentation, the profile is only sourced if bash is run in login. To verify this, I invoked bash --login
, after which rvm
was available.
This has worked for me in previous versions of Ubuntu without any configuration. That is, a fresh install of 10.10 will correctly source profile/.d.
My question is: is there anything I'm doing wrong, or are there some new assumptions being made in Natty that have broken this? My current workaround is to source /etc/profile
in ~/.bashrc
(which is awful as profile is meant to load before bashrc's, but does the trick).
Best Answer
Per default, gnome-terminal does not start bash as a login shell (I assume you mean bash started inside a gnome-terminal). That means bash will not read
/etc/profile
or~/.profile
. As you have correctly observed, bash will read those files if started as a login shell.The quick fix to your problem is to configure gnome-terminal to start bash as a login shell so it will read
/etc/profile
. To do that you have to enable "Run Command as a login shell" in the gnome-terminal "Profile Preferences" reachable from the Edit menu.I do not recommend doing this because it messes up the distinction between
~/.profile
and~/.bashrc
. Ideally~/.profile
should do stuff which is required only once, during login, while~/.bashrc
should do stuff which is required everytime bash is started.There is a question and answer at superuser talking about the difference between bashrc and profile. Read there for more information.
From your problem description it seems that the rvm script needs to be loaded only once, during login. As far as I know Ubuntu has configured the graphical login to read
/etc/profile/
and~/.profile
. That means, after logging out and a logging in once, the rvm script should be active. If it still doesn't work, then perhaps the rvm script needs to be loaded for every bash session. If that is the case thenbashrc
is the more appropriate place for the script.