Replies: 1 comment 7 replies
-
I have the same expectation you have 🤔 I tried writing a spec to represent your situation and it worked as we both expect. Does this sounds like the kind of setup you have? + context "when a top-level gem has an indirect dependency present in the default source, but with a higher version from the one resolved" do
+ before do
+ build_lib "vc_gem", "1.0.0", :path => bundled_app do |s|
+ s.add_dependency "my_gem", "1.0.0"
+ end
+
+ build_repo gem_repo4 do
+ build_gem "my_gem", "1.0.0"
+ build_gem "my_gem", "3.0.0"
+ end
+
+ gemfile <<-G
+ source "https://gem.repo2"
+
+ gemspec
+
+ source "https://gem.repo4" do
+ gem "my_gem"
+ end
+ G
+ end
+
+ it "installs all gems without warning" do
+ bundle :install, :artifice => "compact_index"
+ expect(the_bundle).to include_gem("my_gem 1.0.0")
+ end
+ end
+
|
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When a gem server must be specified, it is currently impossible for gem version requirements to follow the "dry"-paradigm, which can result in some confusing issues.
If I have published a private gem called "my_gem" on a private gemserver, and I have released versions: 1.0.0, 2.0.0, and 3.0.0, each with breaking changes.
If I have an old gem that depends on the older API of 1.0.0, and my Gemspec strictly enforces this:
I have to specify the source in my
Gemfile
:I will end up with a
Gemfile.lock
like this, which is not entirely expected:Note that the placement of the
gemspec
directive makes no difference, whether before or after thesource
block.The only way to get the correct source, and the correct version is to (re)specify the version when specifying the source as follows in the
Gemfile
:The duplicate declaration of the version is problematic, because, if we add two layers to this cake, I have gem, called "llama" that depends on "my_gem" version 1.0.0, and it will have to reduplicate the version in both its gemspec and its Gemfile.
Then, I have an app that depends on "llama", and it will also have to specify each of these gems as coming from the private server. It will have to duplicate, again, the version requirement of the sub-dependencies that are already explicitly set by each gem, but cannot help but be overridden.
Now make this stack of gems, apps, apps mounted inside other apps, many, many more layers deep, and it is a pain.
Beta Was this translation helpful? Give feedback.
All reactions