2

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)
Swaps
  • 1,450
  • 24
  • 31
  • can you copy your gemfile pls ? – Maxence Dec 04 '17 at 17:30
  • I don't think there's a need to paste a whole gemfile here and make the question further bulky as I have pasted whatever errors I am getting while upgrading the rails version using `bundle update rails`. I have specified `gem rails, '5.0.0'` in my gemfile. – Swaps Dec 05 '17 at 05:39
  • 2 things that could help if not already done in your gemfile : mention the Ruby version on top of it (in case it defaults to an old incompatible Ruby version) and remove versioning of all other gems than Rails (which is versionned to 5.0.0) – Maxence Dec 05 '17 at 05:55
  • my ruby version is `2.4.2` which is the latest stable release. – Swaps Dec 05 '17 at 05:57

2 Answers2

0

What is your question?

Before update a gem you have to check if your project code and dependencies are ready for this changes, not an easy process if this is a big app.

1. Come back to de rails version you had.

gem install <gem> -v=<version>

e.g.

gem install rails -v=4.2

This way your rails app should use the version you want.

2. Update the rest of the gems... (not recommend it if you are not sure about the new releases)

Check your Gemfile.lock:

bundle update

Or delete your Gemfile.lock (it will be rebuild automatically when you try to start your rails app).

maguri
  • 386
  • 2
  • 10
  • I am upgrading `rails 4.2` to `rails 5`. So I have updated all gems in my gemfile to the latest version to ensure that all are compatible with `rails 5` (will resolve any other code dependencies on gem version once the rails version is upgraded). – Swaps Dec 05 '17 at 05:34
  • Try to **update/install actionpack** `budle install actionpack -v=5.0.0`. Then you will resolve this issue but probably, you will have other gem dependencies errors. – maguri Dec 05 '17 at 09:37
  • Yes. I even uninstalled all of the gems for `ruby 2.4.2`. – Swaps Dec 06 '17 at 05:24
0

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.

Swaps
  • 1,450
  • 24
  • 31