views:

1164

answers:

2

Hi,

I just installed Ruby Version Manager (RVM) which is working fine but it asked me to put the following line in my /.bash_profile and ~/.bashrc files:

if [[ -s /Users/tammam56/.rvm/scripts/rvm ]] ; then source /Users/tammam56/.rvm/scripts/rvm ; fi

looking at the content I see the following:

tammam56$ cat /.bash_profile
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
if [[ -s /Users/tammam56/.rvm/scripts/rvm ]] ; then source /Users/tammam56/.rvm/scripts/rvm ; fi

tammam56$ cat ~/.bashrc 
export PATH=/usr/local/bin:$PATH
export MANPATH=/usr/local/man:$MANPATH
if [[ -s /Users/tammam56/.rvm/scripts/rvm ]] ; then source /Users/tammam56/.rvm/scripts/rvm ; fi

However when I start new Terminal window it doesn't execute the command I know this as I set my default Ruby verion to 1.9 and if I execute the line manually I get to the correct version:

tammam56$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
Macintosh-37:~ tammam56$ if [[ -s /Users/tammam56/.rvm/scripts/rvm ]] ; then source /Users/tammam56/.rvm/scripts/rvm ; fi
Macintosh-37:~ tammam56$ ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin10.2.0]

Any ideas how I can fix that?

Thanks,

Tam

+1  A: 

Have you confirmed that other commands in .bashrc and/or .bash_profile get updated properly?

Next you should confirm whether Terminal is starting the shell as a login shell or not (see under Preferences -> Startup).

From the bash man page:

When bash is invoked as an interactive login shell, or as a non-inter- active shell with the --login option, it first reads and executes com- mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc.

Ether
Thanks Ether. Looking are preferences > Startup : Shells open with Default login shell (/usr/bin/login). What do you mean by "Have you confirmed that other commands in .bashrc and/or .bash_profile get updated properly?"
Tam
@Tam: try putting `echo "running .bashrc"` in your .bashrc, and `echo "running .bash_profile"` in your .bash_profile -- which of these files are being executed by a new Terminal?
Ether
Thanks Ether. I tried that but I didn't get any display! I guess my bash doesn't execute neither of these files!! I tried @UnderpantsGnome suggestion and it worked! I also added echo "executing .profile" at the bottom of it and saw the output!
Tam
+1  A: 

If you have a ~/.profile try adding the following line to it.

if [[ -s /Users/tammam56/.rvm/scripts/rvm ]] ; then source /Users/tammam56/.rvm/scripts/rvm ; fi

UnderpantsGnome