1

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 Jun 11 '13 at 21:55
2

~/.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.

EDIT

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? – countunique Jun 11 '13 at 22:54
  • @Stuart Sounds like this rvm script is doing something it shouldn't, then. – geirha Jun 12 '13 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? – countunique Jun 12 '13 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 Jun 12 '13 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 Jun 12 '13 at 19:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.