Skip to content

Avoid redundant Caskroom chgrp#22121

Merged
MikeMcQuaid merged 1 commit intomainfrom
fix-linux-caskroom-sudo-prompt
May 2, 2026
Merged

Avoid redundant Caskroom chgrp#22121
MikeMcQuaid merged 1 commit intomainfrom
fix-linux-caskroom-sudo-prompt

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

  • Check the Caskroom group before running chgrp.
  • Share the expected group name between checks and fixes.
  • Keep Linux using sudo when the group must change.

Fixes #22120


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes. Non-maintainers may only have one AI-assisted/generated PR open at a time.

Used OpenAI Codex with substantial local refactoring.


- Check the `Caskroom` group before running `chgrp`.
- Share the expected group name between checks and fixes.
- Keep Linux using `sudo` when the group must change.

Fixes #22120
Copilot AI review requested due to automatic review settings May 2, 2026 11:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces unnecessary sudo prompts during Cask installs by skipping redundant chgrp on the Caskroom when its group is already correct, and by centralizing the expected group name (macOS: admin, Linux: root).

Changes:

  • Skip chgrp in Cask::Caskroom.ensure_caskroom_exists when the directory already has the expected group.
  • Introduce expected_caskroom_group and use it for both group checks and chgrp arguments.
  • Add unit specs covering the new group-check behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Library/Homebrew/cask/caskroom.rb Adds group-correctness check and shared expected group helper to avoid redundant chgrp.
Library/Homebrew/extend/os/linux/cask/caskroom.rb Aligns Linux chgrp implementation with shared expected group helper (still uses sudo).
Library/Homebrew/test/cask/caskroom_spec.rb Adds specs for skipping/performing chgrp and for expected-group checks on macOS/Linux.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/test/cask/caskroom_spec.rb
Comment thread Library/Homebrew/cask/caskroom.rb
@MikeMcQuaid MikeMcQuaid enabled auto-merge May 2, 2026 11:53
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue May 2, 2026
Merged via the queue into main with commit c4e48fd May 2, 2026
38 of 40 checks passed
@MikeMcQuaid MikeMcQuaid deleted the fix-linux-caskroom-sudo-prompt branch May 2, 2026 17:27
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.

Installing cask claude-code on Linux unnecessarily asks for sudo password

3 participants