In my .profile I have the following command,

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Right now, to get my desired behavior I have to type source ~/.profile in the terminal. I would like this to be automatic (since it's in .profile), but it's not. Any ideas?

My .profile is being executed when I login (tested it with export foo=bar).

  • What's in rvm? That looks like the weak link.
    – Paul
    Commented Jun 11, 2013 at 21:55

1 Answer 1


~/.profile is not only used by bash, it's also used by other posix shells. When you log in graphically in Ubuntu, ~/.profile gets sourced by sh, which does not have [[ or source.


After a bit of googling about this rvm stuff, it appears it's a bash script, so switching to posix sh syntax won't work; the script simply does not belong in ~/.profile.

One way to get around it could be to source it from ~/.bashrc instead. The drawback of that is that whatever environment variables it sets, will only be available to bash shells. e.g. commands that rely on these enviornment variables can't be run directly from a launcher.

  • This worked. But, side-effect is that I can no longer login through graphical login manager. When I login, the login screen just closes and then shows again. Do you know why? Commented Jun 11, 2013 at 22:54
  • @Stuart Sounds like this rvm script is doing something it shouldn't, then.
    – geirha
    Commented Jun 12, 2013 at 9:02
  • When I put export foo=$SHELL into my ~/.profile, I get bash as the response. Shouldn't it give sh by what you said? Commented Jun 12, 2013 at 18:34
  • 1
    @Stuart The SHELL environment variable reflects the login shell set in the passwd database (/etc/passwd). It does not reflect what shell you're currently in. To see what shell you're currently in, ps -p $$ will tell you with most shells. With the ps command available in Ubuntu, you can narrow the output with ps -ocmd= -p $$. So: export "foo=$(ps -ocmd= -p $$)".
    – geirha
    Commented Jun 12, 2013 at 19:41
  • 1
    @Stuart At any rate, as far as I know, there's no login shell involved. With gdm, which was used in earlier Ubuntu releases, an sh script was run when you logged in, that specifically sourced ~/.profile before doing an exec gnome-session. Not sure how it's done with lightdm exactly, but it appears to be done similarly.
    – geirha
    Commented Jun 12, 2013 at 19:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .