fix(coding-agent): redo Bun package manager node_modules handling (#3998)
* Revert "fix(coding-agent): use alternate logic to find Bun's node_modules (#3861)"
This reverts commit c241c6d6d0. The logic
is faulty: the original strategy of looking for node_modules by asking
the package manager is not incorrect even on bun. Instead, it should
learn a different method of asking the package manager for node_modules
when the *package manager* is bun, not the *runtime*.
* feat(coding-agent): detect bun as package manager and use alternate root query
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 (simple) check for Bun being used as package manager, and instead
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, isBunRuntime } from "../config.js";
|
||||
import { CONFIG_DIR_NAME } 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,9 @@ export class DefaultPackageManager implements PackageManager {
|
||||
if (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {
|
||||
return this.globalNpmRoot;
|
||||
}
|
||||
if (isBunRuntime) {
|
||||
const binDir = this.runCommandSync("bun", ["pm", "bin", "-g"]).trim();
|
||||
const isBunPackageManager = npmCommand.command === "bun";
|
||||
if (isBunPackageManager) {
|
||||
const binDir = this.runNpmCommandSync(["pm", "bin", "-g"]).trim();
|
||||
this.globalNpmRoot = join(dirname(binDir), "install", "global", "node_modules");
|
||||
} else {
|
||||
this.globalNpmRoot = this.runNpmCommandSync(["root", "-g"]).trim();
|
||||
|
||||
Reference in New Issue
Block a user