fix(tui): avoid update loops for mismatched npm installs

This commit is contained in:
Felipe Coury
2026-05-09 15:32:54 -03:00
parent 0c70698e24
commit d0a905a557
10 changed files with 598 additions and 45 deletions

View File

@@ -2,7 +2,7 @@
// Unified entry point for the Codex CLI.
import { spawn } from "node:child_process";
import { existsSync } from "fs";
import { existsSync, realpathSync } from "fs";
import { createRequire } from "node:module";
import path from "path";
import { fileURLToPath } from "url";
@@ -171,6 +171,12 @@ const packageManagerEnvVar =
? "CODEX_MANAGED_BY_BUN"
: "CODEX_MANAGED_BY_NPM";
env[packageManagerEnvVar] = "1";
try {
env.CODEX_MANAGED_PACKAGE_ROOT = realpathSync(path.join(__dirname, ".."));
} catch {
// Best effort only. Older or unusual package layouts can omit this extra
// provenance without preventing Codex from starting.
}
const child = spawn(binaryPath, process.argv.slice(2), {
stdio: "inherit",