Conflicting Ruby Gems

Managing conflicting versions of ruby gems

To be blunt, you can't have two versions of the same gem loaded at the same time.

Bundler does a good (ish) job of looking through all of the required gems and finding a solution to the various overlapping dependencies, but even so it is limited to only loading one version of a gem at a time.

This leads to plugin developers constantly having to update to support any changes that are made in dependent gems in order to avoid just the situation you describe.

(Don't get me started on the screw up that results from the various competing JSON implementations and the pain you have to go through when you have several gem dependencies all requiring different ones.)

conflicting ruby gems

There's probably no elegant solution to the problem. If you really need the two gems working side by side I think your best option is to fork one of them (or possibly both) and use your fork. This is how I'd go about it:

  • If either gem is hosted on Github then fork it, or if both are on Github fork the one that seems to be the least work.
  • If neither gem is on Github, see if you can get hold of the source (grabbing it from the gem is a possibility, but finding the real repository might be helpful as there may be other files there that are not included in the gem), and put it in a repository on Github. Make sure the gem's license allows this (which it almost certainly does if it's one of the common open source licenses).
  • Make your changes.
  • Make sure there is a .gemspec file in the root of the repository, the next step will not work otherwise.
  • Use Bundler to manage your projects dependencies. Instead of specifying the dependency to the library you've modified as

    gem 'the_gem'

    specify it like this:

    gem 'the_gem', :git => 'git://github.com/you/the_gem.git'

    (but change the URL to the repository to the actual one)

  • Send an e-mail to the maintainer of the gem you modified and ask him or her to consider merging in your changes in the next release.

Bundler makes it really easy to use alternative versions of gems with minimal hassle. I often fork gems, fix bugs or add features, change my Gemfile to point to my version, then ask the maintainer to merge in my changes. When, or if, that happens I simply change my Gemfile back to just refer to the official version of the gem.

An alternative strategy, if the maintainer does not want to merge in your changes and you want to distribute your version to others is to push up your version to Rubygems as a new gem, but in that case prefix the gem name with your name, or some other string that identifies your gem as a variant.

Why is bundle adding an extra 0 at the end of my Ruby version?

Seems like this may have been due to a conflict between gem installed gems and bundle installing the same gems over again.
Doing gem uninstall -aIx and then bundle install may fix this.

Gem dependency conflict

This answer is very late, but you inadvertently upgraded the twitter gem, which was yanked as gruzy notes in a comment here.

Just specify another repo, with a tag that's not broken for you and does not conflict with faraday. For me, this was:

gem 'twitter', :git => 'https://github.com/sferik/twitter.git', :tag => 'v2.2.0'

You probably just replace v2.2.0 with v2.5.0, and the breakage should be gone.

Superclass conflict in two gem dependencies

Unfortunately, you can't do much with it.

You can find the answer here https://stackoverflow.com/a/4497478/6745294



Related Topics



Leave a reply



Submit