StormTrooper
StormTrooper

Reputation: 75

gem path reverts back to previous path

just recently installed ruby 2.3.0 and rails 4.2

ran bundle install for the first time and my app successfully ran from my local server.

added a few gems, and once again ran bundle install... it appears that my previously installed gems were once again being installed.

tried running rails server once again and this came out.

-bash: /usr/local/bin/rails: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory

just making a wild guess here, but i think the gem folder is reverting back to my old folder which is ruby 1.9.1

any form of help would be greatly appreciated.

Upvotes: 0

Views: 543

Answers (2)

Minato
Minato

Reputation: 4533

You can read about different ways to set the app/project environment at rvm project workflows

if you are using rvm to manage the rubies, just add this line at the top of your gem file..

ruby '2.3.0' #or the target version of the app

or

#ruby=2.3.0

and cd back into the directory.. you'll get a warning but just ignore it. now every time you change back to you app directory it'll change the version to the one mentioned in your gem file. the default might be set to some other version..

you can also use

bash --login
rvm use '2.3.0' --default

to set the default version of ruby system wide.

if that doesn't work.. try to check if the correct ruby version is present by

rvm list

and then try using it by

bash --login
rvm use '2.3.0' #or the target version

and to every time switch to the latest version don't do anything above except when installing the version set it to default.. but you'll have to install all the gems again for every binary ruby you install..

P.S. Fixing ruby version for a project/app is a good and safe practice, so I'd recommend you to use the any approach to fix a ruby version for the app, mentioning it in Gemfile is clean, makes sense to me when you only need to set the ruby version.

Note. Do whatever is in @Shrikant1712's answer first if you haven't already or you might run into issues.

Upvotes: 1

shrikant1712
shrikant1712

Reputation: 4446

You have need to install gem bundler using gem install bundler command and then again try to use bundle install command.

(Here I am assuming you have used RVM for installing ruby.)

Still you get same type of error then that means your rvm is not properly set. Please check your $PATH from the following files

  • ~/.profile
  • ~/.bashrc
  • ~/.bash_profile
  • ~/.gemrc

You can use source ~/.rvm/scripts/rvm for setting the rvm.

Upvotes: 0

Related Questions