-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix regression when installing native extensions on universal rubies #7077
Conversation
Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality. We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below. If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack. For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide |
7d0b5d9
to
a163ffb
Compare
Looks good, mind adding a spec for the scenario that this addresses? |
I realized we can avoid code duplication by changing |
Done :) |
@hanyang-tony I tried reverting the fix here, and the spec still passes. Can you have a look? |
Sorry, I was testing the wrong method. I've fixed it now. Due to the nature of how the |
Maybe I'm crazy but the new spec is still passing without this fix? |
This is a fix for 'universal ruby', |
c88e399
to
1ca4fad
Compare
Ideally we'd find a way to test this in our CI, to avoid regressions, even if by mocking the platform somehow. Let's ship the bug fix though for now. |
Since rubygems#6945 the extension dir changed to Gem::BasicSpecification's implementation, we didn't hook that in rubygems_ext.rb. So for universal rubies, we ended up using the universal platform name when installing, but arch replaced platform name when checking. This lead to native extensions can never be correctly installed on universal rubies. Hook Gem::BasicSpecifications so the behavior is consistent on installing and checking.
It's possible to hook |
I've fixed the linting error, can we re-run the actions? |
Can we re-run the failed test? Seems like it was not caused by the changes in this PR. |
Ok, let's ship this as is.
Would happily accept such a test to cover this 👍. |
Fix regression when installing native extensions on universal rubies (cherry picked from commit d79c609)
Fix regression when installing native extensions on universal rubies (cherry picked from commit d79c609)
Fix regression when installing native extensions on universal rubies (cherry picked from commit d79c609)
Fix regression when installing native extensions on universal rubies (cherry picked from commit d79c609)
You could take inspiration from 11229b1 which uses |
I tried to use |
Yeah it's designed to work when running a Bundle process ( |
The regression caused bundler to search gem extension in a different directory than the one which it was installed. The existing tests could work if the tested gem has native extension. |
Since #6945 the extension dir changed to Gem::BasicSpecification's implementation, we didn't hook that in rubygems_ext.rb. So for universal rubies, we ended up using the universal platform name when installing, but arch replaced platform name when checking. This lead to native extensions can never be correctly installed on universal rubies.
Hook Gem::BasicSpecifications so the behavior is consistent on installing and checking.
What was the end-user or developer problem that led to this PR?
For universal rubies, the change from #6945 to def gem_build_complete_path is incorrect. Previously, extension_dir is invoked on the Bundler::StubSpecification, which is a child class of Specification. After the change to stub.gem_build_complete_path, @Stub is actually an instance of Gem::StubSpecification, thus gem_build_complete_path is from Gem::BasicSpecification.
The problem arise when in bundler, we replace the 'universal' part of Gem::Platform with the arch. But we still use the universal name for Gem::Specification, this is defined in 'rubygems_ext.rb'. Now the stub is using extension_dir defined in Gem::BasicSpecification, so the 'universal' part ended up being swapped by arch.
So, we install native extensions to 'extensions/universal-darwin-22/', but finding them in 'extensions/x86_64-darwin-22/'. Leading to native extension gems can never be installed on universal ruby.
What is your fix for the problem, implemented in this PR?
Hook Gem::BasicSpecifications so the behavior is consistent on installing and checking.
Make sure the following tasks are checked