Every time I close terminal rails defaults back to 2.3.5 from 3.0.3?

百般思念 提交于 2019-12-20 06:15:05

问题


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



来源:https://stackoverflow.com/questions/4824139/every-time-i-close-terminal-rails-defaults-back-to-2-3-5-from-3-0-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!