{"record":{"id":"80516fb0456a5a39","repo":"can1357/oh-my-pi","slug":"failed-to-install-packagename-stderr","errorCode":null,"errorMessage":"Failed to install ${packageName}: ${stderr}","messagePattern":"Failed to install (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/extensibility/plugins/installer.ts","lineNumber":64,"sourceCode":"\n\t// Run npm install in plugins directory\n\tconst proc = Bun.spawn([\"bun\", \"install\", packageName], {\n\t\tcwd: PLUGINS_DIR,\n\t\tstdin: \"ignore\",\n\t\tstdout: \"pipe\",\n\t\tstderr: \"pipe\",\n\t\twindowsHide: true,\n\t});\n\n\t// Drain both pipes concurrently with proc.exited to avoid a pipe-buffer\n\t// deadlock if bun install floods stdout/stderr.\n\tconst [exitCode, , stderr] = await Promise.all([\n\t\tproc.exited,\n\t\tnew Response(proc.stdout).text(),\n\t\tnew Response(proc.stderr).text(),\n\t]);\n\tif (exitCode !== 0) {\n\t\tthrow new Error(`Failed to install ${packageName}: ${stderr}`);\n\t}\n\n\t// Extract the actual package name (without version specifier) for path lookup\n\tconst actualName = extractPackageName(packageName);\n\n\t// Read the installed package's package.json\n\tconst pkgPath = path.join(PLUGINS_DIR, \"node_modules\", actualName, \"package.json\");\n\tconst pkgFile = Bun.file(pkgPath);\n\tif (!(await pkgFile.exists())) {\n\t\tthrow new Error(`Package installed but package.json not found at ${pkgPath}`);\n\t}\n\n\tconst pkg = await pkgFile.json();\n\n\treturn {\n\t\tname: pkg.name,\n\t\tversion: pkg.version,\n\t\tpath: path.join(PLUGINS_DIR, \"node_modules\", actualName),","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/extensibility/plugins/installer.ts#L46-L82","documentation":"installPlugin spawns the package manager to install the requested plugin and waits for exit plus collected stdout/stderr. A non-zero exit code throws 'Failed to install <packageName>: <stderr>', surfacing the package manager's stderr as the cause.","triggerScenarios":"bun/npm install exits non-zero: package doesn't exist in the registry, no network, version specifier unresolvable, auth required for a private registry, or peer-dependency conflicts.","commonSituations":"Typo'd package name (404 Not Found); offline/CI without registry access; private registry packages without an auth token; incompatible engine/version constraints; proxy blocks registry.npmjs.org.","solutions":["Read the stderr in the message — it contains the package manager's actual reason.","Verify the package exists: `npm view <packageName>` or check the registry in a browser.","Check network/proxy access to the registry and any required auth tokens (.npmrc).","Install manually with `bun add <packageName>` in the plugins dir to reproduce and debug the exact failure."],"exampleFix":"// before: unresolvable version\nawait installPlugin(\"omp-plugin@^99.0.0\")\n// after\nawait installPlugin(\"omp-plugin@^1.0.0\")","handlingStrategy":"retry","validationCode":"const view = Bun.spawnSync([\"npm\", \"view\", packageName, \"version\"], { stdout: \"pipe\", stderr: \"pipe\" });\nif (view.exitCode !== 0) {\n  throw new Error(`Package not resolvable: ${packageName} (${view.stderr.toString().trim()})`);\n}\nawait installPlugin(packageName);","typeGuard":null,"tryCatchPattern":"try {\n  await installPlugin(pkg);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Failed to install\")) {\n    const transient = /ETIMEDOUT|ECONNRESET|network/i.test(err.message);\n    if (transient) await backoffRetry(() => installPlugin(pkg), 3);\n    else throw new Error(`Install failed permanently: ${err.message}`);\n  } else throw err;\n}","preventionTips":["Verify the package exists in the registry before installing","Ensure registry auth tokens (.npmrc) and proxy settings are present in CI","Use exact or known-good version ranges to avoid unresolvable specifiers"],"tags":["plugins","package-manager","network","process-execution","install"],"backgroundTag":"package-install-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}