Report permission errors from bundle clean - #9772
Open
alloutflo wants to merge 1 commit into
Open
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?
bundle cleanreports that it removed an unused gem and exits successfully even when filesystem permissions prevent the directory from being deleted.FileUtils.rm_rfdeliberately suppresses those removal errors, leaving users with stale files and no indication that cleanup failed.Fixes #9396.
What is your fix for the problem, implemented in this PR?
Use the existing
SharedHelpers.filesystem_accesserror translation aroundFileUtils.rm_r. The raising removal preserves recursive cleanup on success, while Bundler now reports permission failures with the affected path and exits with its permission-error status instead of silently succeeding.The integration regression makes an unused installed gem directory non-writable, runs
bundle clean, and verifies exit status 23, the actionable permission message/path, and that the directory remains. The same example exits 0 against the old implementation and passes with this change.Verification
bin/rspec spec/commands/clean_spec.rb:49— 1 example, 0 failures (and confirmed red against the old implementation)bin/rspec spec/commands/clean_spec.rb— 36 examples, 0 failures, 1 existing pending examplebin/rubocop lib/bundler/runtime.rb spec/commands/clean_spec.rb— no offensesgit diff --check— passedMake sure the following tasks are checked
AI disclosure: I used an AI coding assistant to help inspect the removal/error-handling path, implement the focused fix and regression test, and run the checks above. I reviewed the final diff and red/green evidence before submitting.