Search code examples
ruby-on-railsrvmgemset

How do I upgrade a rails 3.2 app from ruby 1.9.3 to ruby 2.1.5 using rvm


My Rails 3.2 / Ruby 1.9.3 app is using RVM. I want to upgrade to using ruby 2.1.5.

I have used RVM to install Ruby 2.1.5 as well. So rvm list shows both 1.9.3 and 2.1.5

My project directory has a .rvmrc file specifying

environment_id="ruby-1.9.3-p551@current_foogems"

So I have a gemset named current_foogems

How can I switch my project to use ruby 2.1.5?

Do I copy the gemset? Create a new (empty) gemset?

Given the jump in ruby version from 1.9.3 to 2.1.5, which may mean I should recompile gems, I'm thinking the safe approach might be:

i) create a new blank gemset 'new_foogems'
ii) edit the .rvmrc file to use "ruby-2.1.5@new_foogems"
iii) run bundle install to re-create all-new gems in the new gemset

Solution

  • Per comments from @Santiago and @Milind, the answer is to

    1) edit the .rvmrc file and give environment_id a new value such as'= ruby-2.1.5@new_foogems and also edit the Gemfile to specify ruby "2.1.5"

    2) leave directory (cd ..)

    3) go back into directory (to reload the .rvmrc)

    4) says "yes" to alert the .rvmrc file changed

    RVM will create the new blank gemset.

    5) Run rvm install 2.1.5

    6) run bundle install