fix(setup): make --dry-run report macOS-only steps as skipped off macOS (#769)

Off macOS, `rig setup --dry-run` said the `brew` and `cmux_install` steps "would be attempted", but the real run skips both there. The dry run now reports them as skipped with the real run's own messages, which become shared constants. macOS output, step statuses and exit codes are unchanged; only those two messages differ off macOS, including in `--json`. If cmux is already installed off macOS, the real run checks it, while the dry run still reports it as skipped.
This commit is contained in:
adampog authored and GitHub committed 2026-10-05 00:39:17 -07:00
1 parent c36c983581
commit a350c59b5a
2 files changed
+33 -3

No files matched your search

+11 -3
View File
@@ -116,6 +116,13 @@ const CORE_STEP_IDS = [
"verify",
];
const FULL_EXTRA_STEP_IDS = ["jq_install", "gh_install"];
const BREW_PLATFORM_SKIP = "Skipped: Homebrew setup path is only used on macOS.";
const BREW_UNAVAILABLE_SKIP = "Skipped: Homebrew not available.";
/** Steps the real run skips off macOS, with the message it gives (cmux is a macOS app installed via Homebrew). */
const NON_DARWIN_DRY_RUN_SKIPS: Record<string, string> = {
brew: BREW_PLATFORM_SKIP,
cmux_install: BREW_UNAVAILABLE_SKIP,
};
const BASE_RUNTIME_CONFIG_DISCLOSURE: RuntimeConfigDisclosure[] = [
// OPR.0.4.8.2 agnostic rip-out: OpenRig no longer writes ~/.claude/settings.json — the global
// permission allow-list (C2) is removed, so that global file is no longer touched at all.
@@ -362,7 +369,8 @@ export async function runSetup(deps: SetupDeps, opts: { dryRun?: boolean; full?:
if (opts.dryRun) {
for (const id of stepIds) {
steps.push({ id, status: "skipped", message: `Dry run: ${id} would be attempted.` });
const platformSkip = platform !== "darwin" ? NON_DARWIN_DRY_RUN_SKIPS[id] : undefined;
steps.push({ id, status: "skipped", message: platformSkip ?? `Dry run: ${id} would be attempted.` });
}
if (opts.policy !== undefined) {
steps.push({ id: "policy_record", status: "skipped", message: `Dry run: would record permission_policy for '${opts.policy}'.` });
@@ -377,7 +385,7 @@ export async function runSetup(deps: SetupDeps, opts: { dryRun?: boolean; full?:
steps.push({
id: "brew",
status: "skipped",
message: "Skipped: Homebrew setup path is only used on macOS.",
message: BREW_PLATFORM_SKIP,
});
} else {
try {
@@ -505,7 +513,7 @@ export async function runSetup(deps: SetupDeps, opts: { dryRun?: boolean; full?:
}
} catch {
if (!brewOk) {
steps.push({ id: "cmux_install", status: "skipped", message: "Skipped: Homebrew not available." });
steps.push({ id: "cmux_install", status: "skipped", message: BREW_UNAVAILABLE_SKIP });
} else {
try {
installCommand(deps, "brew install --cask cmux");
+22
View File
@@ -169,6 +169,28 @@ describe("rig setup", () => {
expect(execSpy).not.toHaveBeenCalled();
});
it("--dry-run on linux reports the macOS-only steps as skipped with the real run's reasons", async () => {
const dry = await runSetup(makeDeps({ platform: "linux" }), { dryRun: true });
const real = await runSetup(makeDeps({ platform: "linux", exec: (cmd: string) => {
if (cmd === "tmux -V") return "tmux 3.4\n";
throw new Error(`not found: ${cmd}`);
} }), {});
for (const id of ["brew", "cmux_install"]) {
const dryStep = dry.steps.find((s) => s.id === id);
expect(dryStep?.status).toBe("skipped");
expect(dryStep?.message).toBe(real.steps.find((s) => s.id === id)?.message);
}
expect(dry.steps.find((s) => s.id === "brew")?.message).toBe("Skipped: Homebrew setup path is only used on macOS.");
expect(dry.steps.find((s) => s.id === "tmux_install")?.message).toBe("Dry run: tmux_install would be attempted.");
});
it("--dry-run on darwin still reports brew and cmux_install as would be attempted", async () => {
const dry = await runSetup(makeDeps({ platform: "darwin" }), { dryRun: true });
expect(dry.steps.find((s) => s.id === "brew")).toEqual({ id: "brew", status: "skipped", message: "Dry run: brew would be attempted." });
expect(dry.steps.find((s) => s.id === "cmux_install")).toEqual({ id: "cmux_install", status: "skipped", message: "Dry run: cmux_install would be attempted." });
});
it("core profile execution with all tools present returns pass/applied steps and ready=true", async () => {
const writeSpy = vi.fn();
const deps = makeDeps({ writeFile: writeSpy });