fix(coding-agent): use alternate logic to find Bun's node_modules (#3861)
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"
Add a check for the Bun runtime using the logic already used elsewhere,
and build the relative path starting from Bun's bin directory.
This commit is contained in:
@@ -27,7 +27,7 @@ import type { Readable } from "node:stream";
|
||||
import { globSync } from "glob";
|
||||
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";
|
||||
import { canonicalizePath, isLocalPath } from "../utils/paths.js";
|
||||
import { isStdoutTakenOver } from "./output-guard.js";
|
||||
@@ -1843,8 +1843,12 @@ export class DefaultPackageManager implements PackageManager {
|
||||
if (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {
|
||||
return this.globalNpmRoot;
|
||||
}
|
||||
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;
|
||||
return this.globalNpmRoot;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user