简体   繁体   中英

Upgrading Ruby version And Rails Compatibility

Hi guys I wonder if someone could explain the problem I'm having so that I can understand whats going on.

I am currently running ruby 2.2.2 and rails 5. I have a small test app and all is working fine. I decided to upgrade ruby to version 2.4.0, for no other reason than I think I should know how to do it and the resulting pitfalls etc, so a learning exercise.

After updating ruby to 2.4.0 which goes fine the command rails -v returns rails not installed. If i then revert to the older ruby 2.2.2 rvm use ruby-2.2.2 run rails -v then rails 5.0.1 is returned. Whats happening here?

Thanks

RVM gives you a separate gem directory for each and every Ruby version and gemset. This means that gems must be explicitly installed for each revision and gemset. Usually the migration process is as follows:

rvm use ruby-2.4.0 
# or `rvm --default use ruby-2.4.0` if you want to use 2.4.0 from now on
gem install rails -v 5.0.1 # an example, use any version you like
gem install bundler
bundle install # to install all other project gems

See the RVM gemsets documentation page .

Extending @Slava.K 's answer

I have a small test app and all is working fine. I decided to upgrade ruby to version 2.4.0, for no other reason than I think I should know how to do it and the resulting pitfalls etc, so a learning exercise.

  • When you upgrade ruby to 2.4.0, this becomes your new ruby version number, thus you won't have any reference to rails and bundler .
  • You would need to do gem install rails -v xxx and gem install bundler .
  • Now when you do rails -v , this will print a version number of the installed rails for your given Ruby.

After updating ruby to 2.4.0 which goes fine the command rails -v returns rails not installed. If i then revert to the older ruby 2.2.2 rvm use ruby-2.2.2 run rails -v then rails 5.0.1 is returned. Whats happening here?

  • As I have mentioned above already, installing rails is imperative when you upgrade Ruby. So no rails installed, no version number to display

  • gem env home => ../versions/jruby-1.7.12/lib/ruby/gems/shared
    • Will show you the location of installed the gems.
  • I perefer to use rbenv over rvm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM