can1357/oh-my-pi · error · Error

bun pm cache failed: ${cacheResult.stderr}

Error message

bun pm cache failed: ${cacheResult.stderr}

What it means

refreshBunGitCache runs `bun pm cache` in the given cwd before a plugin git update so Bun's cached bare clone is fresh. If the command exits non-zero it throws with the captured stderr. This is the pre-update cache bootstrap for git-hosted plugin installs.

Source

Thrown at packages/coding-agent/src/extensibility/plugins/bun-git-cache.ts:51

		const host = scpLike[1]?.toLowerCase() ?? "";
		const repoPath = (scpLike[2] ?? "").replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
		return `ssh://${host}/${repoPath}`;
	}

	try {
		const parsed = new URL(withoutFragment);
		const repoPath = parsed.pathname.replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
		return `${parsed.protocol.toLowerCase()}//${parsed.host.toLowerCase()}/${repoPath}`;
	} catch {
		return withoutFragment.replace(/\/+$/g, "").replace(/\.git$/i, "");
	}
}

/** Fetches current heads and tags into Bun's matching cached bare clone before a plugin update. */
export async function refreshBunGitCache(source: GitSource, cwd: string): Promise<void> {
	const cacheResult = await runCommand(["bun", "pm", "cache"], cwd);
	if (cacheResult.exitCode !== 0) {
		throw new Error(`bun pm cache failed: ${cacheResult.stderr}`);
	}
	const cacheDir = cacheResult.stdout.trim();
	if (!cacheDir) {
		throw new Error("bun pm cache returned an empty cache path");
	}

	let entries: Dirent[];
	try {
		entries = await fs.readdir(cacheDir, { withFileTypes: true });
	} catch (err) {
		if (isEnoent(err)) return;
		throw err;
	}

	const repositoryUrl = normalizeRepositoryUrl(source.repo);
	for (const entry of entries) {
		if (!entry.isDirectory() || !entry.name.endsWith(".git")) continue;
		const repositoryDir = path.join(cacheDir, entry.name);

View on GitHub (pinned to 9690622007)

Solutions

  1. Run `bun pm cache` manually in the same directory to see the real error.
  2. Ensure bun is installed and on PATH (`which bun`; check version — `bun pm cache` needs a recent bun).
  3. Upgrade bun (`bun upgrade`) if the subcommand is missing.
  4. Fix permissions/home dir issues that prevent bun from accessing its cache.

Example fix

// verify before installing
$ bun pm cache
/Users/you/.bun/install/cache  # must succeed and print a path
Defensive patterns

Strategy: try-catch

Validate before calling

const proc = Bun.spawn(["bun", "pm", "cache"], { stdout: "pipe", stderr: "pipe" });
const [code, out] = await Promise.all([proc.exited, new Response(proc.stdout).text()]);
if (code !== 0 || !out.trim()) throw new Error("bun pm cache unavailable");
// only then call installPlugin/updatePlugin

Type guard

function isBunAvailable(): boolean {
  const which = Bun.which("bun");
  return typeof which === "string" && which.length > 0;
}

Try / catch

try {
  await updateGitPlugin(source, cwd);
} catch (err) {
  if (err instanceof Error && err.message.startsWith("bun pm cache failed:")) {
    logger.warn("Skipping bun cache refresh", { stderr: err.message });
    // proceed without refresh or abort install deliberately
  } else throw err;
}

Prevention

When it happens

Trigger: Installing/updating a git-sourced plugin when `bun pm cache` fails — bun not on PATH, broken bun installation, or the command erroring in the plugin's cwd.

Common situations: bun not installed or an old bun version lacking `pm cache`; restricted environment/CI where bun cannot write its cache dir; PATH differences between shell and the process spawning the installer.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/424e69486ec7febd. Report an issue: GitHub.