Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflicts with default #145

Closed
jrochkind opened this issue Oct 8, 2018 · 5 comments
Closed

conflicts with default #145

jrochkind opened this issue Oct 8, 2018 · 5 comments

Comments

@jrochkind
Copy link

jrochkind commented Oct 8, 2018

I have a Rails engine gem, whose gemspec says "~> 5.2.0" -- since that's what it actually works with.

But I'd like to run tests against rails master too, so I can get early warning if something in master (for eventual Rails 5) breaks it. Probably as an "allowed failure" in travis.

This statement from the docs let me think maybe it would work:

The dependencies in your Appraisals file are combined with dependencies in your Gemfile, so you don't need to repeat anything that's the same for each appraisal. If something is specified in both the Gemfile and an appraisal, the version from the appraisal takes precedence.

But it in fact, it doesn't:

Bundler could not find compatible versions for gem "rails":
  In rails_edge.gemfile:
    rails (>= 6.0.0.alpha)

    kithe was resolved to 0.1.0, which depends on
      rails (~> 5.2.1)

(Or, if I don't explicitly put ">= 6.0.0.alpha" in my Appraisals file, then:

Bundler could not find compatible versions for gem "rails":
  In rails_edge.gemfile:
    rails

    kithe was resolved to 0.1.0, which depends on
      rails (~> 5.2.1)

Any ideas/advice for how to accomplish this?

@jrochkind
Copy link
Author

jrochkind commented Oct 8, 2018

I think I found a hacky way to do it, with this in my gemspec:

  # Should never release a gemspec with this set, but needed so we can test
  # against other rails versions (like edge) in Appraisal
  unless ENV['APPRAISAL_INITIALIZED']
    s.add_dependency "rails", "~> 5.2.1"
  end

@jrochkind
Copy link
Author

I tried again without things in gemspec dependencies, just literally a dependency specified in the Gemfile, and then again (with different requirements) in an appraisal.

Now I got eg:

[!] There was an error parsing rails_5_0.gemfile: You cannot specify the same gem twice with different version requirements.
You specified: rails (~> 5.0.0) and rails (>= 0). Bundler cannot continue.

Is the statement in the docs simply no longer true? "If something is specified in both the Gemfile and an appraisal, the version from the appraisal takes precedence." Is this supposed to be true? How do I get it to work?

@nickcharlton
Copy link
Member

Oh huh, that's interesting.

Have you been able to come up with a better solution since then?

Part of me is wondering if this is a specific library@HEAD sort of problem, but one which would be good to solve.

@jrochkind
Copy link
Author

jrochkind commented Feb 10, 2020

I'm not totally sure how I resolved that in the 16 months since reported; I don't recall that coming up again, I'm not sure if it's because the problem doesn't always happen (depending on bundler/rubygems versions?) or I've avoided ever double-specifying.

I can think of situations where it would be hard to avoid double-specifying... I do think its' a use case that would ideally be supported. I'm not sure what's going on for me, I had forgotten about this.

Perhaps I am still working around with the workaround mentioned above, guarding a Gemfile with unless ENV['APPRAISAL_INITIALIZED'] to avoid double-specifying. That is a little bit error-prone of a situation, need to make sure you are keeping your Gemfile in sync with whatever's going on in your appraisal gemfiles.

@nickcharlton
Copy link
Member

Yeah, totally. I'm going to close this for now, but if you're struggling with it again, please reopen.

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

No branches or pull requests

2 participants