Rails 4 on OSX: trouble with always having to reinstall rails on new terminal window/new session

StackOverflow https://stackoverflow.com/questions/21852186

  •  13-10-2022
  •  | 
  •  

Question

This has proven to be a pretty odd issue and I'm rather confused by it. I know there is plenty of documentation and SO q/a on this but I'm still pretty stuck.

I've been using this tutorial:

http://blog.nicoschuele.com/posts/install-rails-4-correctly-on-os-x-mountain-lion

which has actually been pretty helpful.

Maybe it's my bashrc file, but I'm really not sure.

The problem:

I started a new rails project, all was going swimmingly. I cmd+t in the current terminal session to open a new tab. Do a rails -v and it's giving me the good ole 'sudo gem install rails` message.

Same thing happens if I close out of Terminal completely and reopen. the ruby -v has never seemed to be an issue: ruby is always there and rvm doesn't seem to be an issue.

This is my bashrc file which I access by doing vi ~/.bashrc

  1 export PATH=$HOME/local/bin:$PATH
  2 export ANDROID_HOME=/usr/local/opt/android-sdk
  3 export ANDROID_SDK=/usr/local/Cellar/android-sdk/22.3
  4 
  5 PATH=$PATH:$HOME/.rvm/src/rvm/bin # Add RVM to PATH for scripting
  6 
  7 
  8 PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
  9 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
 10 
 11 ### Added by the Heroku Toolbelt
 12 export PATH="/usr/local/heroku/bin:$PATH"

My bash_profile is the following:

  1 if [ -f ~/.bashrc ];
  2 then
  3     source ~/.bashrc
  4 fi
  5 
  6 source ~/.profile
  7 
  8 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"     # Load RVM into a shell session *as a function*  

If anyone could offer some insight as to why I need to keep installing rails, I would greatly appreciate it.

Was it helpful?

Solution

It seems if you put the following line

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"     # Load RVM into a shell session *as a function*  

into bash_profile you can potentially run into issues.

I ended up removing the above from bash_profile and putting it at the bottom of bashrc.

Yes, I had to install rails again (NOT using sudo, just gem install rails --no-ri --no-rdoc) for the app at hand but it seems this has solved the situation at hand:

I can close terminal, cd back into the rails app directory, do a rails -v and it returns rails 4.0.2

I can open new tabs in current terminal session, do a rails -v within the rails project directory and it returns rails 4.0.2

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top