Skip to content

[Bug]: Inherited NPM_CONFIG_PREFIX overrides the managed ACP npm prefix on Windows #38697

Closed

Description

@amitse

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server (ACP Registry)

Steps to reproduce

  1. On Windows, set $env:NPM_CONFIG_PREFIX = 'C:\example\inherited-npm' in PowerShell, then launch T3 Code from that shell.
  2. Add an npm-distributed ACP Registry agent whose exact package version is available. The managed npm commands in AcpRegistrySupport.ts copy the inherited environment and add a lowercase npm_config_prefix.
  3. To verify the collision without installing anything, save this as repro.cjs and run node repro.cjs from the same shell. Replace the npm CLI path if Node.js is installed elsewhere.
const { spawnSync } = require("node:child_process");
const npm = "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js";
const env = { ...process.env, npm_config_prefix: "C:\\example\\t3-managed" };
const args = [npm, "prefix", "--global"];
const prefix = () => spawnSync(process.execPath, args, { env, encoding: "utf8" }).stdout.trim();
console.log("Both spellings:", prefix());
delete env.NPM_CONFIG_PREFIX;
console.log("Managed spelling only:", prefix());

Expected behavior

T3's npm subprocesses use the managed prefix, regardless of how the inherited prefix variable is capitalized.

Actual behavior

I verified the following output on Windows:

Both spellings: C:\example\inherited-npm
Managed spelling only: C:\example\t3-managed

On Windows, Node passes only one of the case-insensitive duplicate environment keys to the child process. The inherited uppercase key wins here, so the managed npm commands can target a user or system prefix instead of T3's per-agent directory. The subprocess repro does not require network access or modify any packages.

Impact

Major degradation or frequent failure when an uppercase npm prefix is set.

Version or commit

T3 Code Beta 0.1.10 (7d32075). I also checked that the same environment merge is present on main.

Environment

Windows 11 x64, Node.js 26.13.1, npm 11.20.0.

Workaround

Remove NPM_CONFIG_PREFIX from the environment used to launch T3 Code if it is not needed there. T3 can avoid the collision by removing all inherited spellings of that key from the copied Windows environment before setting the managed prefix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions