Preserve native extensions during implicit clean - #9800
Merged
hsbt merged 1 commit intoAug 24, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was the end-user or developer problem that led to this PR?
Fixes #9795.
When a native gem is already activated from the system gem path, an implicit
clean after
bundle installcan use that system installation's extension pathfor the project-local stub. It then treats the still-required extension under
BUNDLE_PATHas stale and removes it silently.What is your fix for the problem, implemented in this PR?
Reload a stub's own gemspec when
Gem::StubSpecification#to_specreturns anactivated specification from a different installation. This keeps the local
specification and extension paths together when implicit clean computes its
stale directories.
The regression test activates the system copy of a native gem, installs the
same version into
BUNDLE_PATH, and changes an unrelated locked gem whileBUNDLE_CLEAN=true. It verifies that cleanup removes the obsolete gem butpreserves the required local native extension.
Make sure the following tasks are checked
Testing
bin/rspec spec/commands/install_spec.rb:2065bin/rspec spec/bundler/stub_specification_spec.rb spec/commands/install_spec.rbbin/rake rubocopPATH="/tmp/oss-rspec-bin:$PATH" bin/rake spec:all(3 existing non-TTY color expectation failures; the same examples fail on the recorded upstream commit)