earendil-works/pi · error · Error

Failed to run

Error message

Failed to run ${[command, ...args].join(" ")}: ${reason}

What it means

Thrown by readCommandOutput in config.ts when a helper process (e.g. git for worktree detection, or a bun binary probe) exits non-zero with requireSuccess set; the reason is the spawn error message, stderr, or exit code. This is a wrapper for an external-tool failure, not a config syntax problem.

Solutions

  1. Run the failing command manually to see the real error
  2. Fix the underlying tool issue (missing binary, bad exit path, permissions)
  3. Check that the expected binary is installed and on PATH
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/coding-agent/src/config.ts:202 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/f1d219b1d85fdbb5. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/config.ts:202

		}
		case "unknown":
			return undefined;
	}
}

function readCommandOutput(
	command: string,
	args: string[],
	options: { requireSuccess?: boolean } = {},
): string | undefined {
	const result = spawnProcessSync(command, args, {
		encoding: "utf-8",
		stdio: ["ignore", "pipe", "pipe"],
	});
	if (result.status === 0) return result.stdout.trim() || undefined;
	if (options.requireSuccess) {
		const reason = result.error?.message || result.stderr.trim() || `exit code ${result.status ?? "unknown"}`;
		throw new Error(`Failed to run ${[command, ...args].join(" ")}: ${reason}`);
	}
	return undefined;
}

function getGlobalPackageRoots(method: InstallMethod, _packageName: string, npmCommand?: string[]): string[] {
	switch (method) {
		case "npm": {
			const configured = !!npmCommand?.length;
			const [command = "npm", ...npmArgs] = npmCommand ?? [];
			if (configured && command === "bun") {
				const bunBin = readCommandOutput(command, [...npmArgs, "pm", "bin", "-g"], {
					requireSuccess: true,
				});
				const roots = [join(homedir(), ".bun", "install", "global", "node_modules")];
				if (bunBin) {
					roots.push(join(dirname(bunBin), "install", "global", "node_modules"));
				}
				return roots;

View on GitHub (pinned to 4af9d21d3b)