Every time I close terminal rails defaults back to

2019-03-05 03:37发布

问题:

I'm going through the rails by example tutorial.

Its seems that every time I close terminal rails defaults back to 2.3.5 & I have to go through the process of installing 3.0.3 every time I open the terminal?

I installed rails using: $ [sudo] gem install rails --version 3.0.3

Has anyone experienced a similar issue? I've tried googling around and searching stack to no avail.

回答1:

Try uninstalling the rails gem:

gem uninstall rails

If you are prompted to select a version, select 2.3.5 and leave the 3.0.3 version intact.

P.S: Are you using RVM? If not, I would highly recommend it.



回答2:

The problem is almost-assuredly RVM interpreting 2.3.5 as your default rails version in your default gem set. I ran into this problem myself when first experimenting with RVM. Try this:

rvm --default use 1.9.2 (or whatever you want your default ruby interpreter to be)
rvm gemset create rails-3.0.3
rvm use 1.9.2@arails-3.0.3 --default
gem install rails

That will:

  • Set your default ruby interpreter to the desired ruby version
  • Create a gemset for your Rails 3.0.3 install and make it your default gemset
  • Install rails

Once you close the terminal and open it back up, it'll load RVM's defaults, putting you back on Rails 3.0.3 again.



回答3:

I've had this problem using RVM, if you're using RVM do: $rvm 1.9.2 (or whatever ruby version you installed the rails 3 gem with).

Check the output of $ ruby -v when you seem to have access to rails3 and again $ ruby -v when you can only seem to get to v2.3.5. If it shows different versions of ruby then you most likley are using RVM.



回答4:

@Ads If youre using RVM and you install rails using sudo like so

$ [sudo] gem install rails --version 3.0.3

youre doing it wrong. RVM depends on you using a ruby distro that was installed by RVM into your user directory. If youre using sudo, youre installing rails gem into your system-wide ruby.

So check that youre using the right ruby version by doing 'rvm info' and then do your 'gem install rails --version 3.0.3' without sudo