Thursday, May 5, 2016

Upgrading Rails version



I was doing some maintenance in an old application, still using Rails 4.2.4, and decided to move it to Rails 4.2.6.

I updated my .ruby-version to contain the string 4.2.6 and then update my Gemfile accordingly. Everything was fine and then I executed my bundle install.

This was the result:

Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Resolving dependencies...............
Bundler could not find compatible versions for gem "actionpack":
  In snapshot (Gemfile.lock):
    actionpack (= 4.2.4)

  In Gemfile:
    rails (= 4.2.6) was resolved to 4.2.6, which depends on
      actionpack (= 4.2.6)

    sass-rails (~> 5.0) was resolved to 5.0.4, which depends on
      railties (< 5.0, >= 4.0.0) was resolved to 4.2.4, which depends on
        actionpack (= 4.2.4)

    sass-rails (~> 5.0) was resolved to 5.0.4, which depends on
      sprockets-rails (< 4.0, >= 2.0) was resolved to 3.0.4, which depends on
        actionpack (>= 4.0)

What it says is there is a conflict between the new Rails version and the old auxiliary gems like ActionPack.

When this happens you may run bundle update, of course, but there is another solution. You may just delete your Gemfile.lock and run bundle install again.