Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Unable to resolve dependencies when using prerelease gem #2938

Closed
alexrothenberg opened this issue Mar 24, 2014 · 7 comments
Closed

Unable to resolve dependencies when using prerelease gem #2938

alexrothenberg opened this issue Mar 24, 2014 · 7 comments

Comments

@alexrothenberg
Copy link

I expected this Gemfile to resolve with the 3.0.0.beta2 versions of all rspec gems

source 'https://rubygems.org'

gem 'rspec-rails', '3.0.0.beta2'
gem 'rspec', '>=2.2'
Bundler could not find compatible versions for gem "rspec-mocks":
  In Gemfile:
    rspec (>= 2.2) ruby depends on
      rspec-mocks (~> 2.2) ruby

    rspec-rails (= 3.0.0.beta2) ruby depends on
      rspec-mocks (3.0.0.beta2)

I extracted this from a more complicated example alexrothenberg/ammeter#24 where the gem 'rspec', '>=2.2' dependency wasn't in the top level Gemfile but inside another gem.

Is this intended behavior or a bug? It was certainly surprising behavior to me but I'm not sure what the logic is around prerelease gems.

@indirect
Copy link
Member

Did you try Bundler 1.6? 'gem install bundler --pre'

On Mon, Mar 24, 2014 at 3:47 PM, Alex Rothenberg notifications@github.com
wrote:

I expected this Gemfile to resolve with the 3.0.0.beta2 versions of all rspec gems

source 'https://rubygems.org'
gem 'rspec-rails', '3.0.0.beta2'
gem 'rspec', '>=2.2'
Bundler could not find compatible versions for gem "rspec-mocks":
  In Gemfile:
    rspec (>= 2.2) ruby depends on
      rspec-mocks (~> 2.2) ruby
    rspec-rails (= 3.0.0.beta2) ruby depends on
      rspec-mocks (3.0.0.beta2)

I extracted this from a more complicated example alexrothenberg/ammeter#24 where the gem 'rspec', '>=2.2' dependency wasn't in the top level Gemfile but inside another gem.

Is this intended behavior or a bug? It was certainly surprising behavior to me but I'm not sure what the logic is around prerelease gems.

Reply to this email directly or view it on GitHub:
#2938

@Who828
Copy link
Contributor

Who828 commented Mar 25, 2014

I think in this case even bundler 1.6.0.RC2 won't help, the problem is Rspec-rails is pointing to 3.0.0.beta2 which is a pre-release version and Rspec on the other hand is pointing to 2.2 which is a non-prerelease version of the gem.

So while resolving dependency, it considers this 2.14.1 as the latest version for Rspec and that depends on a Rspec-mock (2.14.1) so it will always fail to resolve (since it can't find 3.0.0.beta2).

As for the fix, we can't obviously fetch pre-release versions of the gem if gem in Gemfile is pointing to non-prerelease version. We can either be clear about our resolving policies in documentation or add a flag like (:pre_release => true) which would also take account of pre_release gems versions as well. (for that gem)

@indirect
Copy link
Member

Ah, I see what you're saying. This is deliberate. Rubygems explicitly excludes prereleases unless the version requirement has an alphabetical number in it. So your version requirements, as stated, are actually in conflict. If you want a prerelease, use '>= 2.2a'.

On Mon, Mar 24, 2014 at 3:47 PM, Alex Rothenberg notifications@github.com
wrote:

I expected this Gemfile to resolve with the 3.0.0.beta2 versions of all rspec gems

source 'https://rubygems.org'
gem 'rspec-rails', '3.0.0.beta2'
gem 'rspec', '>=2.2'
Bundler could not find compatible versions for gem "rspec-mocks":
  In Gemfile:
    rspec (>= 2.2) ruby depends on
      rspec-mocks (~> 2.2) ruby
    rspec-rails (= 3.0.0.beta2) ruby depends on
      rspec-mocks (3.0.0.beta2)

I extracted this from a more complicated example alexrothenberg/ammeter#24 where the gem 'rspec', '>=2.2' dependency wasn't in the top level Gemfile but inside another gem.

Is this intended behavior or a bug? It was certainly surprising behavior to me but I'm not sure what the logic is around prerelease gems.

Reply to this email directly or view it on GitHub:
#2938

@Who828
Copy link
Contributor

Who828 commented Mar 25, 2014

Specifying the version as ">= 2.2a" resolves the Gemfile on 1.6.0.RC2.

EDIT: I guess we could add this into our documentation (if its not already there!).

@alexrothenberg
Copy link
Author

The error messages change with bundler 1.6.0.rc2 but the problem is still there.

I see how prerelease versions are complicated and what I'm about to say could cause problems but what I expected ">=2.2" to mean is a) "anything released 2.2 or greater" and b) "don't get a prerelease version on my account but if some other gem wants one I'm willing as long as its above 2.2". It seems that it only means (a).

The problem gets more difficult when the dependency is not in my Gemfile but in a gem I use and I can't change the version to ">=2.2a".

If I change the example to

source 'https://rubygems.org'

gem 'rspec-rails', '3.0.0.beta2'
gem 'ammeter', '0.2.9'
Bundler could not find compatible versions for gem "rspec-mocks":
  In Gemfile:
    ammeter (= 0.2.9) ruby depends on
      rspec (>= 2.2) ruby depends on
        rspec-mocks (~> 2.2) ruby

    rspec-rails (= 3.0.0.beta2) ruby depends on
      rspec-mocks (3.0.0.beta2)

The ammeter.gemspec includes s.add_runtime_dependency 'rspec', '>= 2.2' which causes the same problem.

I hoped adding gem 'rspec-mocks', '3.0.0.beta2 to the Gemfile might fix the problem but with that I still get

Bundler could not find compatible versions for gem "rspec-mocks":
  In Gemfile:
    ammeter (= 0.2.9) ruby depends on
      rspec (>= 2.2) ruby depends on
        rspec-mocks (~> 2.2) ruby

    rspec-mocks (3.0.0.beta2)

I actually am the ammeter maintainer so I could release a beta version of ammeter but that seems like a burden to place on app devs that they need to use the betas of both rspec-rails and ammeter and the ammeter and rspec-rails teams need to coordinate beta releases. Just a little more information where this issue is coming from.

Also I want to thank you for maintaining this gem and helping me think through this issue :)

@indirect
Copy link
Member

So the thing about prereleases is... they are explicitly only for people to opt in to. So it is by design that it is not possible to simply install rspec and get 3.0.beta when you run gem install rspec -v '>= 2.2'. As a result of that underlying decision about prereleases, it is in fact expected that you will change your gemspec (probably to something like ">= 2.2", "< 4.0" if you are compatible with 3.0, and rspec will not break backwards compatibility).

@alexrothenberg
Copy link
Author

My understanding now is that if I have an app that depends on both rspec and ammeter (which internally depends on rspec-rails >=2.2) . Without a new version of ammeter that depends allows the prerelease dependency there's no way for me to test my app against the prerelease of rspec3. I tried changing the dependency in ammeter to ">= 2.2", "< 4.0" but still got the same error. Once rspec3 releases it will all start working again.

In the case of ammeter I realized I can remove the dependency so avoid the issue so it should all be academic for me. Again thank you for taking the time to help me understand!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants