Repository navigation
fix(brew): support cask command wrappers and run steps - #11472
Conversation
📝 WalkthroughWalkthroughChangesHomebrew cask lifecycle
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CaskMetadata
participant execute_flight_steps
participant CmdLineRunner
participant sudo_run
CaskMetadata->>execute_flight_steps: structured run step
execute_flight_steps->>execute_flight_steps: evaluate guards and expand templates
execute_flight_steps->>CmdLineRunner: execute expanded argv
execute_flight_steps->>sudo_run: execute with sudo when configured
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR expands Homebrew cask compatibility.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the prior literal-wrapper issue is resolved because Important Files Changed
Reviews (3): Last reviewed commit: "fix(brew): harden cask lifecycle metadat..." | Re-trigger Greptile |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ff0d21b. Configure here.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/system/packages/brew/cask.rs (1)
1949-1982: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winPrefer failing fast over panicking for wrapper shape/env validation.
Two small hardening points:
- Line 1981: the
content/executableinvariant is only enforced by the parser, not the type, sounreachable!turns an internal misuse into a panic mid-install.bail!keeps it a normal error.- Line 1963:
is_shell_env_namerejects bad env names only after the archive is downloaded and extracted; validating inparse_command_wrapper_artifactsurfaces bad metadata before any work is done.♻️ Proposed change for the unreachable arm
- _ => unreachable!("command wrapper shape is validated while parsing"), + _ => bail!( + "brew-cask: command_wrapper '{}' must set exactly one of content or executable", + wrapper.name + ),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/system/packages/brew/cask.rs` around lines 1949 - 1982, Replace the unreachable! fallback in the command-wrapper content/executable match with bail! so invalid wrapper shapes return a normal installation error instead of panicking. Also move the is_shell_env_name validation from the executable-building branch into parse_command_wrapper_artifact, ensuring every wrapper environment key is validated before archive download or extraction while preserving the existing invalid-name error.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/system/packages/brew/cask.rs`:
- Around line 2729-2753: Update the run-command path validation after the base
mapping so FlightPathBase::Absolute also rejects relative paths containing
separators or parent-directory components, while continuing to allow bare names
for PATH resolution and absolute paths. Ensure invalid baseless paths fail
during parsing with the existing invalid run-command path error.
---
Nitpick comments:
In `@src/system/packages/brew/cask.rs`:
- Around line 1949-1982: Replace the unreachable! fallback in the
command-wrapper content/executable match with bail! so invalid wrapper shapes
return a normal installation error instead of panicking. Also move the
is_shell_env_name validation from the executable-building branch into
parse_command_wrapper_artifact, ensuring every wrapper environment key is
validated before archive download or extraction while preserving the existing
invalid-name error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: d9be23f0-1fbf-482c-912d-e44f85e16876
📒 Files selected for processing (2)
docs/bootstrap/packages/brew.mdsrc/system/packages/brew/cask.rs
Instruction counts
No instruction-count regression above 1%. Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.
|

Summary
command_wrapperartifacts using executable/args/env or literal contentrunlifecycle steps with serialized command bases, template expansion, guards, environment variables, and mise's sudo policyContext
Homebrew recently introduced
command_wrapperartifacts and migrated cask flight commands to structuredrunsteps. mise parsed cask metadata before its installed-state check and intentionally rejected unknown artifacts and step types, so affected casks began failing even when they were already installed.This addresses the regression reported in discussion #11462, including the Firefox
command_wrapperand OrbStackpostflight_stepsexamples.Generated wrappers use the existing transactional binary-link and receipt paths. Structured commands support the command bases and fields currently emitted by Homebrew while unsupported lifecycle operations continue to fail explicitly.
Validation
mise run lint-fixcargo test --bin mise system::packages::brew::cask::tests -- --test-threads=1(94 passed)git diff --checkAI-assisted — Tool: Codex; model: OpenAI/GPT-5; version: unavailable.
Note
Medium Risk
Touches cask install/linking and can run arbitrary commands (including sudo) from cask metadata, but behavior is scoped to Homebrew’s serialized formats with explicit unsupported-feature errors.
Overview
Fixes regressions where casks such as Firefox (
command_wrapper) and OrbStack (structuredpostflight_stepsrun) failed because mise rejected newer Homebrew artifact metadata.command_wrapperartifacts are parsed, staged under.homebrew-command-wrappers(literalcontentor generated bash fromexecutable/args/envwith template expansion), symlinked into the prefix like binaries, and included in install verification and receipt reconciliation when wrappers are added to an already-installed cask.Structured lifecycle
runsteps execute serialized commands withstaged_path,appdir,homebrew_prefix, and absolute bases; expand Homebrew-style templates; honor platform/path guards; and use mise’s normal or sudo execution path. Preflight structured steps now receiveappdirand run before app install, matching Homebrew’s phase ordering.Docs in
brew.mddescribe command-wrapper andrunstep support.Reviewed by Cursor Bugbot for commit 232f5d8. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation