ruby-on-railsrubyrubygemsdependenciesgemfile

Gemfile requires a newer version of a dependency


So when I'm creating a new Rails Project

rails new test

I have this issue.

You have already activated error_highlight 0.3.0, but your Gemfile requires error_highlight 0.6.0. Since error_highlight is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports error_highlight as a default gem.

If I delete the line of code "error_highlight", ">= 0.4.0", platforms: [:ruby] of my Gemfile the application runs without a problem.

Or If I went to the Gemfile and change "gem "error_highlight", ">= 0.4.0", platforms: [:ruby]" to "gem "error_highlight", ">= 0.3.0", platforms: [:ruby]" and I went to Gemfile.lock (where it was "error_highlight (0.6.0)" and "error_highlight (>= 0.6.0)" to "error_highlight (0.3.0)" and "error_highlight (>= 0.3.0)". The command "rails s" starts working.

I'm wondering if it could cause me problems in the future and if I'm dealing with the problem in the best way

What can I do to run rails new test without receiving this error?

Rails version 7.1.2

Ruby version 3.1.2p20

Bundler version 2.5.4


Solution

  • Some options:

    1. Instead of removing the gem from the Gemfile, try specifying the same gem as the one already installed and activated: gem 'error_highlight', '0.3.0'
    2. Uninstall the current installed and activated gem and install the one you are using in your Rails project:
    gem uninstall error_highlight -v 0.3.0
    gem install error_highlight -v 0.6.0
    

    As a side note, if you are not using Rbenv yet, it would be a good time to do it. It can solve some of these issues as it helps manage different Ruby version requirements for different projects.

    Hopefully, one of the options solves the issue.