What happened?
When "npmCommand": ["bun"] is configured in settings.json, pi fails to start because it invokes bun root -g, which doesn't exist:
error: Failed to run bun root -g: error: Script not found "root"
I'd like to send a PR fixing this by adding a simple check for the Bun runtime, using the Bun-checking logic already in config.ts:
diff --git a/packages/coding-agent/src/core/package-manager.ts b/packages/coding-agent/src/core/package-manager.ts
index a8e996ae..296681c4 100644
--- a/packages/coding-agent/src/core/package-manager.ts
+++ b/packages/coding-agent/src/core/package-manager.ts
@@ -18,3 +18,3 @@ import ignore from "ignore";
import { minimatch } from "minimatch";
-import { CONFIG_DIR_NAME } from "../config.js";
+import { CONFIG_DIR_NAME, isBunRuntime } from "../config.js";
import { type GitSource, parseGitUrl } from "../utils/git.js";
@@ -1834,4 +1834,8 @@ export class DefaultPackageManager implements PackageManager {
}
- const result = this.runNpmCommandSync(["root", "-g"]);
- this.globalNpmRoot = result.trim();
+ if (isBunRuntime) {
+ const binDir = this.runCommandSync("bun", ["pm", "bin", "-g"]).trim();
+ this.globalNpmRoot = join(dirname(binDir), "install", "global", "node_modules");
+ } else {
+ this.globalNpmRoot = this.runNpmCommandSync(["root", "-g"]).trim();
+ }
this.globalNpmRootCommandKey = commandKey;
(Bun doesn't provide a direct analogue for root -g.) Applied locally, this fixes the problem and lets pi start and use extensions. (pi add ... already works fine with bun, as it simply calls bun install -g ..., which works fine.)
This was previously reported unnoticed in #2544.
Steps to reproduce
- Add
"npmCommand": ["bun"] to pi's settings.json.
- Install Bun and use it to install pi:
bunx @mariozechner/pi-coding-agent.
Expected behavior
I expect pi to start when using bun as the package manager - especially as it already has explicit support for Bun as runtime in several other places.
Version
0.70.2
What happened?
When
"npmCommand": ["bun"]is configured in settings.json, pi fails to start because it invokesbun root -g, which doesn't exist:I'd like to send a PR fixing this by adding a simple check for the Bun runtime, using the Bun-checking logic already in
config.ts:(Bun doesn't provide a direct analogue for
root -g.) Applied locally, this fixes the problem and lets pi start and use extensions. (pi add ...already works fine withbun, as it simply callsbun install -g ..., which works fine.)This was previously reported unnoticed in #2544.
Steps to reproduce
"npmCommand": ["bun"]to pi'ssettings.json.bunx @mariozechner/pi-coding-agent.Expected behavior
I expect pi to start when using
bunas the package manager - especially as it already has explicit support for Bun as runtime in several other places.Version
0.70.2