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 1/4] 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, From 3c29f2805964533a2a3b88eba191dd5fa95d14ca Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Wed, 25 Mar 2026 13:43:42 -0400 Subject: [PATCH 2/4] Update changefile. --- .../fix-rush-pnpm-npm-config-warnings_2026-03-23-18-16.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 219d8b24232..fbb584fa9c9 100644 --- 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 @@ -2,7 +2,7 @@ "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.", + "comment": "Fix \"Unknown env config\" warnings from npm during rush-pnpm operations by passing pnpm configuration via CLI args instead of NPM_CONFIG_* environment variables.", "type": "none" } ], From a5683218ad3a481ffd6efc4d30ee012edc549929 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:53:09 +0000 Subject: [PATCH 3/4] revert previous RushPnpmCommandLineParser changes; fix RushVersionSelector instead Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/e3e81359-dd04-4186-979b-7a62e0a663e3 --- .../rush-lib/src/cli/RushPnpmCommandLineParser.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts index 3a04deb7a73..1980c57f085 100644 --- a/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts +++ b/libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts @@ -432,16 +432,12 @@ export class RushPnpmCommandLineParser { const rushConfiguration: RushConfiguration = this._rushConfiguration; const workspaceFolder: string = this._subspace.getSubspaceTempFolderPath(); const pnpmEnvironmentMap: EnvironmentMap = new EnvironmentMap(process.env); - - // 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}`]; + pnpmEnvironmentMap.set('NPM_CONFIG_WORKSPACE_DIR', workspaceFolder); if (rushConfiguration.pnpmOptions.pnpmStorePath) { - pnpmConfigArgs.push(`--store-dir=${rushConfiguration.pnpmOptions.pnpmStorePath}`); - pnpmConfigArgs.push(`--config.cacheDir=${rushConfiguration.pnpmOptions.pnpmStorePath}`); - pnpmConfigArgs.push(`--config.stateDir=${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); } if (rushConfiguration.pnpmOptions.environmentVariables) { @@ -477,7 +473,7 @@ export class RushPnpmCommandLineParser { try { const { exitCode } = await Utilities.executeCommandAsync({ command: rushConfiguration.packageManagerToolFilename, - args: [...pnpmConfigArgs, ...this._pnpmArgs], + args: this._pnpmArgs, workingDirectory: process.cwd(), environment: pnpmEnvironmentMap.toObject(), keepEnvironment: true, From 15761c818eb66ab599d1feb0d4c967ce6c696531 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:59:02 +0000 Subject: [PATCH 4/4] fix: filter npm-incompatible .npmrc properties in RushVersionSelector When the Rush version selector uses npm to install a different version of rush-lib, the .npmrc from the repo is synced but pnpm-specific properties (like hoist, publish-branch, email, etc.) were not being filtered out. This caused npm to emit "Unknown env config" and "Unknown project config" warnings. Add filterNpmIncompatibleProperties: true to the installPackageInDirectoryAsync call in RushVersionSelector, matching the pattern already used in InstallHelpers.ensureLocalPackageManagerAsync(). Fixes #5704 Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/e3e81359-dd04-4186-979b-7a62e0a663e3 --- apps/rush/src/RushVersionSelector.ts | 5 ++++- .../fix-rush-pnpm-npm-config-warnings_2026-03-23-18-16.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/rush/src/RushVersionSelector.ts b/apps/rush/src/RushVersionSelector.ts index 1b87e66e5fd..615aaa0e356 100644 --- a/apps/rush/src/RushVersionSelector.ts +++ b/apps/rush/src/RushVersionSelector.ts @@ -62,7 +62,10 @@ export class RushVersionSelector { // different implementations of the same version of the same package. // This was needed for: https://github.com/microsoft/rushstack/issues/691 commonRushConfigFolder: configuration ? configuration.commonRushConfigFolder : undefined, - suppressOutput: true + suppressOutput: true, + // Filter out npm-incompatible properties (e.g. pnpm-specific settings) from .npmrc + // since this installation always uses npm regardless of the repo's package manager. + filterNpmIncompatibleProperties: true }); console.log(`Successfully installed Rush version ${version} in ${expectedRushPath}.`); 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 index fbb584fa9c9..c34b0155c3b 100644 --- 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 @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@microsoft/rush", - "comment": "Fix \"Unknown env config\" warnings from npm during rush-pnpm operations by passing pnpm configuration via CLI args instead of NPM_CONFIG_* environment variables.", + "comment": "Filter npm-incompatible properties from .npmrc when installing rush-lib via npm, to eliminate spurious \"Unknown env config\" and \"Unknown project config\" warnings.", "type": "none" } ],