Skip to content

Fix "Unknown env config" npm warnings during rush-pnpm operations#5716

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/investigate-fix-for-issue-5704
Draft

Fix "Unknown env config" npm warnings during rush-pnpm operations#5716
Copilot wants to merge 1 commit intomainfrom
copilot/investigate-fix-for-issue-5704

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

rush-pnpm publish emits spurious npm warnings because RushPnpmCommandLineParser._executeAsync() passes pnpm configuration via NPM_CONFIG_* environment variables, which leak to npm when pnpm delegates to npm's registry libraries internally.

npm warn Unknown env config "cache-dir". This will stop working in the next major version of npm.
npm warn Unknown env config "state-dir". This will stop working in the next major version of npm.
npm warn Unknown env config "store-dir". This will stop working in the next major version of npm.
npm warn Unknown env config "workspace-dir". This will stop working in the next major version of npm.

PR #5574 fixed .npmrc content filtering for rush install/install-run but did not cover the rush-pnpm code path.

Changes

  • Replace NPM_CONFIG_WORKSPACE_DIR, NPM_CONFIG_STORE_DIR, NPM_CONFIG_CACHE_DIR, NPM_CONFIG_STATE_DIR env vars with pnpm CLI args (--config.workspaceDir, --store-dir, --config.cacheDir, --config.stateDir)
  • Consistent with BaseInstallManager which already uses CLI args (--store, --config.cacheDir, --config.stateDir) for the same purpose during rush install/rush update

Note: The "Unknown project config" warnings for email/publish-branch originate from the project .npmrc file itself and are outside the scope of this change. Users seeing those should consider using rush publish (which supports .npmrc-publish) or removing deprecated properties from their .npmrc.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants