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

ぐ巨炮叔叔 提交于 2019-12-02 08:59:45

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.

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.

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.

@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

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