Yesterday I spent some time getting Ruby up and running on my Mac, with the intent of playing with Octopress. Today, I wanted to go back to a Grails app I had been working on, when I realized that Grails was no longer in my PATH. Somehow, my PATH variable had been "hijacked" by the Ruby or RVM installs. I immediately started to investigate the issue.
$> grails run-app -bash: grails: command not found[/sourcecode" frameborder="0" allowfullscreen>First, I double checked my ~/.profile file, where I added Grails to my PATH. This was unchanged, but Grails was stil not being added to my PATH.
export GRAILS_HOME=~/Tools/grails-1.3.7 export PATH=/opt/local/bin:/opt/local/sbin:$GRAILS_HOME/bin:$PATHOk, so .profile was no longer being run when I opened Terminal. Interesting. Now if you are a Unix sys admin, the solution will seem immediately apparent. I had a strong suspicion that the issue was that some ~/.bash* files were being run instead of the .profile. I Googled around and learned more about how about the differences between ~/.bash_profile, ~/.bash_login, ~/.bashrc, and my ~/.profile.
Turns out my suspicion was correct. The Ruby RVM installation had created a .bashrc, and now when my Bash shell logged in, it only ran the .bash* files and not my .profile. In order to fix this, I had to tell Bash to load both my .profile and my .bashrc. A simple way to do this was to add the following two lines to my ~/.bash_profile:
. ~/.profile . ~/.bashrcOnce this was added and I reloaded Terminal, my Grails path entries were back and Ruby was still working fine. Success!
For more on how Bash shell operates, check these useful resources out: