Search code examples
ruby-on-railsruby-on-rails-4ruby-on-rails-5bundlergemfile

Gem dependencies incompatibality during upgrade of rails 4.2.10 to rails 5.0.0


I am in a middle of a process of upgrading our rails 4 app. Following the rails upgrade guide, I have updated current rails version in a gemfile replacing 4.2.10 with 5.0.0.

But after running bundle update rails, I am getting many incompatibility issues even after running 4.2.10 (with rails 4.2.10) which should update all gems to the latest version.

Following are the compatibility errors I am getting after running bundle update rails with rails 5.0.0 in a gemfile:

Bundler could not find compatible versions for gem "actionpack":
  In Gemfile:
    active_link_to was resolved to 1.0.3, which depends on
      actionpack

    active_model_serializers was resolved to 0.10.2, which depends on
      actionpack (< 6, >= 4.1)

    inherited_resources was resolved to 1.6.0, which depends on
      actionpack (< 5, >= 3.2)

    inherited_resources was resolved to 1.6.0, which depends on
      actionpack (< 5, >= 3.2)

    kaminari was resolved to 0.17.0, which depends on
      actionpack (>= 3.0.0)

    rails (= 5.0.0) was resolved to 5.0.0, which depends on
      actionpack (= 5.0.0)

    rails (= 5.0.0) was resolved to 5.0.0, which depends on
      actionpack (= 5.0.0)

    rspec-rails (= 3.6.0) was resolved to 3.6.0, which depends on
      actionpack (>= 3.0)

Solution

  • Finally after many trials & testing, I was able to run bundle install. Listing steps that I tried-

    1. Create a new demo rails app using rails new with rails 5.

    2. Remove existing Gemfile.lock.

    3. Remove all current gems: (I used for i in gem list --no-versions; do gem uninstall -aIx $i; done command referenced from here.)

    4. Replace existing Gemfile with the new one that was generated from creating new rails 5 app. (assuming you'll be having a backup copy of existing Gemfile.)

    5. Copy individual gems from old file to the new one.

    6. Run bundle install. (You should be having a :) after this execution.)

    7. Run rails app:update to continue with the upgrade process.