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 task/spec.to_ruby uses current platform, not spec.platform #6056

Open
byteit101 opened this issue Nov 11, 2022 · 3 comments
Open

gem task/spec.to_ruby uses current platform, not spec.platform #6056

byteit101 opened this issue Nov 11, 2022 · 3 comments

Comments

@byteit101
Copy link

Describe the problem as clearly as you can

This seems similar to #147 in that @platform and @original_platform differ, and original_platform is being used for spec.to_ruby.

When building with something that calls spec.to_ruby, the original platform is kept, and a gem with the suffix of the new platform is generated, but the manifest lists the incorrect platform

Did you try upgrading RubyGems?

Yes

Post steps to reproduce the problem

  • bundler gem examplegem
  • Add spec.platform=Gem::Platform.local (and fix the TODO's) in the gemspec
  • Change the rakefile to the below
  • rake doit && tar xfO pkg/examplegem-0.1.0-java.gem metadata.gz | zcat | grep platform; rm -rf pkg

Note the output of the "java" gem: platform: x86_64-linux. This is incorrect

Rakefile

require 'rubygems/package_task'
require 'bundler'
task :doit do
	spec = Gem::Specification::load("examplegem.gemspec").dup
	spec.platform = Gem::Platform.new("java")
	#p spec.to_ruby
	task = Gem::PackageTask.new(spec)
	task.define
	task(:gem).invoke()
end

Workaround

Modifying the Rakefile to set the undocumented original_platform spec.original_platform = spec.platform = Gem::Platform.new("java") outputs the correct result:

platform: java
byteit101 added a commit to byteit101/subspawn that referenced this issue Nov 11, 2022
@deivid-rodriguez
Copy link
Member

@byteit101 Thanks for reporting this! It seems that you digged quite a bit into this. Amazed how we can still get connections to issues from 2011 😲.

Do you have any suggestions to fix this, or even better, would you be willing to give it a try yourself?

@deivid-rodriguez
Copy link
Member

Actually, is this as simple as changing Gem::Specification#to_ruby to use #original_platform instead of #platform?

@byteit101
Copy link
Author

I would have thought it was the reverse, as it uses original_platform today:

result << " s.platform = #{ruby_code original_platform}"

@byteit101 byteit101 changed the title gem task/spec.to_ruby use current platform, not spec.platform gem task/spec.to_ruby uses current platform, not spec.platform Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants