GemBundler failed to solve version conflict #2122

Closed
bachue opened this Issue Oct 15, 2012 · 10 comments

Comments

Projects
None yet
4 participants

bachue commented Oct 15, 2012

Hi,
I thought GemBundler should good at solving version conflict, when there are several gems depend on the same gem(but not the same version), GemBundler should find a profit version which can meet all demands of dependencies. But when I did an experiment, it failed.

I wrote all the commands I used and my bundler/gem/rvm/ruby info into https://gist.github.com/3893119
Can anyone help me? Thanks.

Owner

indirect commented Oct 16, 2012

Bundler somehow sees one of your gems as depending on json 1.7.5, which isn't what's in your gemspecs. Something else weird must be going on.

Contributor

xaviershay commented Aug 13, 2013

Here is your gist translated into a script you can just run. Confirm this is still an issue on 1.3.5.

#!/bin/bash

set -ex

mkdir -p /tmp/repro-2122
cd /tmp/repro-2122

bundle gem json1
cd json1
cat > json1.gemspec <<EOF
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
\$LOAD_PATH.unshift(lib) unless \$LOAD_PATH.include?(lib)
require 'json1/version'

Gem::Specification.new do |gem|
  gem.name          = "json1"
  gem.version       = Json1::VERSION
  gem.authors       = ["Bachue Zhou"]
  gem.email         = ["bachue.shu@gmail.com"]
  gem.description   = %q{description}
  gem.summary       = %q{summary}
  gem.homepage      = ""

  gem.files         = \`git ls-files\`.split($/)
  gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
  gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
  gem.require_paths = ["lib"]
  gem.add_dependency 'json', '>= 1.7.3' # important
end
EOF
gem build json1.gemspec
cd ..

bundle gem json2
cd json2
cat > json2.gemspec <<EOF
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
\$LOAD_PATH.unshift(lib) unless \$LOAD_PATH.include?(lib)
require 'json2/version'

Gem::Specification.new do |gem|
  gem.name          = "json2"
  gem.version       = Json2::VERSION
  gem.authors       = ["Bachue Zhou"]
  gem.email         = ["bachue.shu@gmail.com"]
  gem.description   = %q{description}
  gem.summary       = %q{summary}
  gem.homepage      = ""

  gem.files         = \`git ls-files\`.split($/)
  gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
  gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
  gem.require_paths = ["lib"]
  gem.add_dependency 'json', '<= 1.7.4' # important
end
EOF
gem build json2.gemspec
cd ..
mkdir test-project
cd test-project
gem unpack ../json1/json1-0.0.1.gem
gem unpack ../json2/json2-0.0.1.gem

cat > Gemfile <<EOF
source :rubygems

gem 'json1', '0.0.1', :path => 'json1-0.0.1/'
gem 'json2', '0.0.1', :path => 'json2-0.0.1/'
EOF

bundle install

# ------------------
# expected:
# Fetching gem metadata from http://rubygems.org/..
# Installing json (1.7.4) with native extensions
# Using json1 (0.0.1) from source at json1-0.0.1/
# Using json2 (0.0.1) from source at json2-0.0.1/
# Using bundler (1.2.1)
# Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
# ------------------
# actual:
# Fetching gem metadata from http://rubygems.org/..
# Bundler could not find compatible versions for gem "json":
#   In Gemfile:
#     json2 (= 0.0.1) ruby depends on
#       json (<= 1.7.4) ruby
#
#     json1 (= 0.0.1) ruby depends on
#       json (1.8.0)
# ------------------
# # My explanation:
# # Here I wrote 2 gems:
# # json1, which depends on json >= 1.7.3
# # json2, which depends on json <= 1.7.4
# # And I created a project, use these 2 gems
# # When I run "bundle install", bundler should install json plugin, whose version is >= 1.7.3 and <= 1.7.4
# # So I think bundler should install json 1.7.4, but actually it failed.

@indirect indirect closed this Jan 9, 2014

bachue commented Jan 9, 2014

@indirect Is this issue resolved?

Owner

indirect commented Jan 9, 2014

@bachue you failed to confirm the issue on 1.3.5 for five months. In the meantime, we've rewritten the resolver and fixed a lot of bugs. Please let us know if the issue is still present in master or in one of the forthcoming 1.6 prereleases.

bachue commented Jan 15, 2014

@indirect OK, I've tried and it's still not fixed.

➜ ~/test-project  bundle
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "json":
  In Gemfile:
    json2 (>= 0) ruby depends on
      json (<= 1.7.4) ruby

    json1 (>= 0) ruby depends on
      json (1.8.1)
➜ ~/test-project  bundle --version
Bundler version 1.3.5
Owner

indirect commented Jan 15, 2014

Thanks! We'll take a look. @Who828, any thoughts?

Member

Who828 commented Jan 15, 2014

I ran the script by @xaviershay and it resolved correctly for me. (https://gist.github.com/Who828/8431402)
Are you on Bundler 1.6.0.pre-1? It won't resolve with Bundler 1.5.2 (i.e. the current release or 1.3.5 for that matter)

bachue commented Jan 15, 2014

@Who828 Oh, sorry, I just tested it on 1.3.5 and 1.5.2. Thanks for notice.

bachue commented Jan 15, 2014

@indirect OK, I confirmed, this bug resolved in 1.6.0.pre.1. Thanks!

Member

Who828 commented Jan 15, 2014

@bachue Thanks a lot for helping us out, really appreciate it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment