Search code examples
ruby-on-railsrubyrubygemscountries

Circular dependency on Gemfile


I'm having this error while running bundle install:

Your Gemfile requires gems that depend on each other, creating an infinite loop. Please remove gem 'casein' and try again.

The error started when I added the gem countries to Gemfile.

I think it's a weird bug, because countries and casein have very different dependencies:

Puelos-Macbook:ChataBackend paulo$ gem dependency countries
Gem countries-0.11.4
  currencies (~> 0.4.2)
  i18n_data (~> 0.7.0)
  rspec (>= 3, development)
  yard (>= 0, development)

Puelos-Macbook:ChataBackend paulo$ gem dependency casein
Gem casein-5.0.0.0
  authlogic (= 3.4.2)
  casein (>= 0)
  jquery-rails (>= 0)
  scrypt (= 1.2.1)
  will_paginate (= 3.0.5)

edit:

Just to be sure, I removed all other gems from my Gemfile:

source 'https://rubygems.org'

gem 'countries'
gem 'casein', '5.0.0'

But the error persists


Solution

  • Oh, sorry, I didn’t get this at the first glance.

    casein gem references itself:

    Puelos-Macbook:ChataBackend paulo$ gem dependency casein
    Gem casein-5.0.0.0
      authlogic (= 3.4.2)
      !! NB⇒ casein (>= 0)
      jquery-rails (>= 0)
      scrypt (= 1.2.1)
      will_paginate (= 3.0.5)
    

    It was allowed for bundle prior to 1.9, but disallowed now. You have two options:

    1. downgrade bundler to 1.8 and re-run bundle install.
    2. clone the casein gem, patch casein.gemspec by removing self-reference and submit a pull-request. https://github.com/spoiledmilk/casein3/blob/master/casein.gemspec#L103

    NB Actually this was already done by community, e.g. https://github.com/russellquinn/casein So, you might simply require that version explicitly via gem 'casein', git: 'github.com:russellquinn/casein'.

    Hope it helps.