Take the 2-minute tour ×

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

share|improve this question
add comment

4 Answers

up vote 29 down vote accepted

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. Read this answer for a good explanation on this topic.

From your problem description it seems that the rvm script needs to be loaded only once, during login. As far as I know, Ubuntu reads /etc/profile/ and ~/.profile during login (the graphical login, independent of bash). 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 then bashrc is the more appropriate place for the script.

share|improve this answer
Setting 'run command as a login shell' did indeed load /etc/profile (and thus the .d's). Thanks for the explanation - it seems like this requires follow up with the rvm folk. –  Marc May 5 '11 at 18:24
Ubuntu 11.04 doesn't seem to read /etc/profile and ~/.profile during login. It's strange because it always worked with older versions. I think this is not a solution but a workaround. –  neon May 9 '11 at 10:06
@lesmana Is there a way I could enable "Run Command as a login shell" from CLI instead of GUI? I'm sshed into a remote server and cant forward X locally. –  Waseem May 3 '13 at 8:11
add comment

Installing RVM as multiuser requires the user to run this command:

(because Ubuntu does not source /etc/profile.d at the login)

echo '[[ -s "/etc/profile.d/rvm.sh" ]] && . "/etc/profile.d/rvm.sh" # Load RVM function' >> ~/.bashrc
share|improve this answer
Ubuntu does source the files in /etc/profile.d/ during login because the default /etc/profile loops through, and sources, the files in /etc/profile.d/. However, if this rvm.sh contains code for interactive shells, such as functions or aliases, having them sourced by /etc/profile is pointless. Setup for interactive bash sessions must be in .bashrc. –  geirha Mar 13 '12 at 20:28
add comment

There is, however, a file /etc/bash.bashrc that is read by gnome-terminal and is the "system-wide .bashrc file for interactive bash(1) shells."

My call to the rvm function, [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" , went in there, and works just fine for the couple of users on that system.

share|improve this answer
gnome-terminal does nothing of the sort. gnome-terminal runs bash (or whatever your login shell is set to in the passwd database) in interactive mode, and bash started interactively reads /etc/bash.bashrc. Well, at least on Debian/Ubuntu. Bash normally does not read a system wide bashrc; debian has patched it to do so. –  geirha Mar 13 '12 at 20:24
@geirha : dmitri@Eos:~$ uname -a Linux Eos 3.0.0-16-generic #29-Ubuntu SMP Tue Feb 14 12:48:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux dmitri@Eos:~$ cat /etc/bash.bashrc # System-wide .bashrc file for interactive bash(1) shells. # To enable the settings / commands in this file for login shells as well, # this file has to be sourced in /etc/profile. # If not running interactively, don't do anything [ -z "$PS1" ] && return ..... –  Dmitri Mar 14 '12 at 15:56
Yes, obviously, gnome-terminal invokes bash to read that file: if your shell is ksh, then gnome-terminal wouldn't read that file, would it? May I suggest looking up the word "pedant" in the dictionary before you continue using provocative phrases like "does nothing of the sort." –  Dmitri Mar 14 '12 at 16:05
add comment

if you have ZSH or OH-MY-ZSH, your profile is /etc/zprofile

share|improve this answer
add comment

Your Answer


