From addee0fd00a4c6fb7dd61c06baacd46f7f6ef4d2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 18:31:45 +0000 Subject: [PATCH] fix: convert NPM_CONFIG env vars to CLI args in rush-pnpm to prevent npm warnings In RushPnpmCommandLineParser._executeAsync(), replace NPM_CONFIG_* environment variables (STORE_DIR, CACHE_DIR, STATE_DIR, WORKSPACE_DIR) with pnpm CLI arguments (--store-dir, --config.cacheDir, --config.stateDir, --config.workspaceDir). This prevents these pnpm-specific configuration values from leaking to npm when pnpm internally delegates to npm libraries (e.g. during publish operations), which caused "Unknown env config" warnings. This approach is consistent with how BaseInstallManager already passes these values via CLI args during rush install/update. Fixes #5704 Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/c306dd18-490c-4a52-a3ca-3447740f7280 --- ...-pnpm-npm-config-warnings_2026-03-23-18-16.json | 10 ++++++++++ .../rush-lib/src/cli/RushPnpmCommandLineParser.ts | 14 +++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 common/changes/@microsoft/rush/fix-rush-pnpm-npm-config-warnings_2026-03-23-18-16.json diff --git a/common/changes/@microsoft/rush/fix-rush-pnpm-npm-config-warnings_2026-03-23-18-16.json b/common/changes/@microsoft/rush/fix-rush-pnpm-npm-config-warnings_2026-03-23-18-16.json new file mode 100644 index 00000000000..219d8b24232 --- /dev/null +++ b/common/changes/@microsoft/rush/fix-rush-pnpm-npm-config-warnings_2026-03-23-18-16.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix \"Unknown env config\" warnings from npm during rush-pnpm operations (e.g. publish) by passing pnpm configuration via CLI args instead of NPM_CONFIG_* environment variables.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} diff --git a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts index 1980c57f085..3a04deb7a73 100644 --- a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts +++ b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts @@ -432,12 +432,16 @@ export class RushPnpmCommandLineParser { const rushConfiguration: RushConfiguration = this._rushConfiguration; const workspaceFolder: string = this._subspace.getSubspaceTempFolderPath(); const pnpmEnvironmentMap: EnvironmentMap = new EnvironmentMap(process.env); - pnpmEnvironmentMap.set('NPM_CONFIG_WORKSPACE_DIR', workspaceFolder); + + // Pass pnpm configuration as CLI args rather than NPM_CONFIG_* environment variables. + // Using env vars like NPM_CONFIG_STORE_DIR would cause "Unknown env config" warnings + // when pnpm internally delegates to npm (e.g. during publish operations). + const pnpmConfigArgs: string[] = [`--config.workspaceDir=${workspaceFolder}`]; if (rushConfiguration.pnpmOptions.pnpmStorePath) { - pnpmEnvironmentMap.set('NPM_CONFIG_STORE_DIR', rushConfiguration.pnpmOptions.pnpmStorePath); - pnpmEnvironmentMap.set('NPM_CONFIG_CACHE_DIR', rushConfiguration.pnpmOptions.pnpmStorePath); - pnpmEnvironmentMap.set('NPM_CONFIG_STATE_DIR', rushConfiguration.pnpmOptions.pnpmStorePath); + pnpmConfigArgs.push(`--store-dir=${rushConfiguration.pnpmOptions.pnpmStorePath}`); + pnpmConfigArgs.push(`--config.cacheDir=${rushConfiguration.pnpmOptions.pnpmStorePath}`); + pnpmConfigArgs.push(`--config.stateDir=${rushConfiguration.pnpmOptions.pnpmStorePath}`); } if (rushConfiguration.pnpmOptions.environmentVariables) { @@ -473,7 +477,7 @@ export class RushPnpmCommandLineParser { try { const { exitCode } = await Utilities.executeCommandAsync({ command: rushConfiguration.packageManagerToolFilename, - args: this._pnpmArgs, + args: [...pnpmConfigArgs, ...this._pnpmArgs], workingDirectory: process.cwd(), environment: pnpmEnvironmentMap.toObject(), keepEnvironment: true,