Skip to content

Report permission errors from bundle clean - #9772

Open
alloutflo wants to merge 1 commit into
ruby:masterfrom
alloutflo:agent/issue-9396-clean-permission-errors
Open

Report permission errors from bundle clean#9772
alloutflo wants to merge 1 commit into
ruby:masterfrom
alloutflo:agent/issue-9396-clean-permission-errors

Conversation

@alloutflo

Copy link
Copy Markdown

What was the end-user or developer problem that led to this PR?

bundle clean reports that it removed an unused gem and exits successfully even when filesystem permissions prevent the directory from being deleted. FileUtils.rm_rf deliberately 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_access error translation around FileUtils.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 example
  • bin/rubocop lib/bundler/runtime.rb spec/commands/clean_spec.rb — no offenses
  • git diff --check — passed

Make sure the following tasks are checked

  • Describe the problem / feature
  • Write tests for the bug fix
  • Write code to solve the problem
  • Follow the current code style and use a meaningful commit message without tags

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permissions errors are silently swallowed in bundle clean

1 participant