Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sourcing rvm from my Ubuntu .profile only works manually, not at login

I'm having trouble getting the Ruby Version Manager rvm to source from my Ubuntu 10.04 .profile. The code:

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

...never does what I expect it to (i.e. give me the rvm program when I open a new shell or start a new session); but if I execute

source .profile

in a new shell after logging in, it works! Why will it work when I manually source it, but not automatically at login?

like image 743
bschuth Avatar asked Oct 23 '10 16:10

bschuth


2 Answers

It would appear that Ubuntu handles it's logon scripts differently than most other linux distros

http://ubuntuforums.org/showpost.php?p=9127226&postcount=6

The above post has hints that GDM logins in Ubuntu don't process .bash_profile or .profile the way most other linux distros do. I have had to put the line loading RVM in the ~/.bashrc and that has not caused any problems yet.

like image 139
BeepDog Avatar answered Oct 24 '22 14:10

BeepDog


Sourcing $HOME/.rvm assumes you have installed RVM a single user, specially, the user whose home directory is $HOME. Likely, on your Ubuntu system, RVM has been installed system wide, and thus you must source the RVM scripts as such:

In your .bashrc file add:

\# Set rvm path

[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm"

before this line; this line will exit and not execute anything past it, which is fine for interactive logins, bit would be a problem is you are using non-interactive SSH logins for automation purposes.

\# If not running interactively, don't do anything

[ -z "$PS1" ] && return
like image 3
DJM Avatar answered Oct 24 '22 13:10

DJM