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

Gem in gemspec without ruby platform version is resolved to a wrong platform #3200

Closed
toy opened this issue Oct 29, 2017 · 7 comments · Fixed by #4015
Closed

Gem in gemspec without ruby platform version is resolved to a wrong platform #3200

toy opened this issue Oct 29, 2017 · 7 comments · Fixed by #4015
Labels

Comments

@toy
Copy link
Contributor

toy commented Oct 29, 2017

I've stumbled upon an issue with using bundler for developing a gem that has a dependency on sys-proctable gem. The issue seems to be caused by two characteristics of sys-proctable gem: it has only platform specific versions and two of them (darwin and freebsd) have additional dependency on ffi gem. I was able to reproduce the behaviour on freebsd (10.3) and osx (darwin 16).

Given Gemfile:

source 'https://rubygems.org'
gemspec

and test.gemspec:

Gem::Specification.new do |s|
  s.name        = 'test'
  s.version     = '1.0.0'
  s.summary     = 'test summary'
  s.authors     = ['Max Mustermann']
  s.add_dependency 'sys-proctable', '~> 1.0'
end

and running bundle on freebsd, produces:

Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/.
Resolving dependencies...
Unable to use the platform-specific (universal-freebsd) version of sys-proctable (1.1.5) because it has different dependencies from the universal-aix5 version. To use the platform-specific version of the gem, run `bundle config specific_platform true` and install again.
Using bundler 1.15.4
Fetching sys-proctable 1.1.5 (universal-aix5)
Installing sys-proctable 1.1.5 (universal-aix5)
Using test 1.0.0 from source at `.`
Bundle complete! 1 Gemfile dependency, 3 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

Running bundle config specific_platform true, removing the sys-proctable gem from the system and repeating bundle will remove the warning, but will still fetch the universal-aix5 platform specific gem.

@segiddins
Copy link
Member

Reproduces on my machine, thanks for the report!

@segiddins
Copy link
Member

Following spec reproduces the issue:

diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb
index f38f73384..64a616de6 100644
--- a/spec/runtime/platform_spec.rb
+++ b/spec/runtime/platform_spec.rb
@@ -115,4 +115,27 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
       expect(the_bundle).to include_gems "platform_specific 1.0 RUBY"
     end
   end
+
+  it "works with a `gemspec` that depends upon a multi-platform gem" do
+    simulate_platform "x86-darwin-100"
+
+    build_repo4 do
+      %w[universal-aix5 universal-darwin].each do |pl|
+        build_gem("bar") do |s|
+          s.platform = pl
+        end
+      end
+    end
+
+    build_lib("foo", "1.0", :path => bundled_app) do |s|
+      s.add_runtime_dependency "bar"
+    end
+
+    install_gemfile! <<-G
+      source "file:#{gem_repo4}"
+      gemspec
+    G
+
+    expect(the_bundle).to include_gems 'foo 1.0', "bar 1.0 universal-darwin"
+  end
 end

@hsbt hsbt transferred this issue from rubygems/bundler Mar 14, 2020
@deivid-rodriguez
Copy link
Member

deivid-rodriguez commented Oct 15, 2020

Hello! 👋 👋

I run Samuel's spec and it passes now! So it sounds like we might've fixed this with the recent multiplatform improvements! 🎉

@toy Could you verify that this is now working fine?

@toy
Copy link
Contributor Author

toy commented Oct 15, 2020

@deivid-rodriguez Using bundler 2.2.0.rc.2 if I change the dependency to s.add_dependency 'sys-proctable', '~> 1.1.0' (as sys-proctable 1.2.x doesn't have platform specific versions) I still see the warning and universal-aix5 version is installed.

@deivid-rodriguez
Copy link
Member

Interesting, I guess the issue doesn't repro with that spec after all. It does work if you set specific_platform setting as suggested, right?

@toy
Copy link
Contributor Author

toy commented Oct 18, 2020

Setting the specific_platform makes it get and lock on right platform gem.
It is even a bit easier to reproduce than in my original post, given Gemfile:

source 'https://rubygems.org'
gemspec

and test.gemspec:

Gem::Specification.new do |s|
  s.name        = 'test'
  s.version     = '1.0.0'
  s.summary     = 'test summary'
  s.authors     = ['Max Mustermann']
  s.add_dependency 'sys-proctable', '~> 1.1.0'
end

and running bundle on osx will contain in the output:

Unable to use the platform-specific (universal-darwin) version of sys-proctable (1.1.5) because it has different dependencies from the universal-aix-5 version. To use the platform-specific version of the gem, run `bundle config set specific_platform true` and install again.
Using bundler 2.2.0.rc.2
Using sys-proctable 1.1.5 (universal-aix-5)

It is enough to delete Gemfile.lock and to run:

bundle config specific_platform true
bundle

To lock on the right gem.

It may be important that sys-proctable doesn't have version 1.1.5 with platform ruby.

@deivid-rodriguez
Copy link
Member

Great! The plan is currently to remove the specific_platform setting and enable it by default. So I guess this can be closed once we do that?

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

Successfully merging a pull request may close this issue.

5 participants