Search code examples
ruby-on-railsdependenciesrubygemsbundler

Bundler could not find compatible versions for gem. The version is within range


Bundler is giving this error when I run bundle install, but actionmailer 5.2.6 is within the range >= 5.2 and < 8! Why is it giving an error? It's doing this for multiple gems. The dependency is within range for all of them.

Bundler could not find compatible versions for gem "actionmailer":
  In Gemfile:
    exception_notification (~> 4.2) was resolved to 4.5.0, which depends on
      actionmailer (< 8, >= 5.2)

    rails (~> 5.2.6) was resolved to 5.2.6, which depends on
      actionmailer (= 5.2.6)

Here is an example of another nonsensical error. Obviously 5.0 <= 5.2.6 < 7:

Bundler could not find compatible versions for gem "rails":
  In Gemfile:
    rails (~> 5.2.6)

    rails_admin (~> 2.0.1) was resolved to 2.0.2, which depends on
      rails (>= 5.0, < 7)

I deleted Gemfile.lock. Bundler version 2.3.9. Gemfile


Solution

  • It was because of this line:

    gem 'flip', '~>1.1', :git => 'https://github.com/pda/flip.git'
    

    When commented, it works. When uncommented, it spits out nonsensical errors and buried in the errors is this:

    Bundler could not find compatible versions for gem "activesupport":
      In Gemfile:
        flip (~> 1.1) was resolved to 1.1.1, which depends on
          activesupport (>= 4.0, <= 5.2)
    
        rails (~> 5.2.6) was resolved to 5.2.6, which depends on
          activesupport (= 5.2.6)
    

    I think that is the ONLY error it should have printed out, but that is probably a bug in Bundler. Now I must manually implement that Gem or think of a monkey patch. (I dislike unnecessary and superficial dependencies.)