Skip to content

fix(@angular/cli): copy project config files to temp directory during ng update#32959

Open
ptu14 wants to merge 1 commit intoangular:mainfrom
ptu14:fix/ng-update-copy-project-npmrc
Open

fix(@angular/cli): copy project config files to temp directory during ng update#32959
ptu14 wants to merge 1 commit intoangular:mainfrom
ptu14:fix/ng-update-copy-project-npmrc

Conversation

@ptu14
Copy link
Copy Markdown

@ptu14 ptu14 commented Apr 8, 2026

Fixes #27163

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

During ng update, the CLI installs a temporary version of itself in a system temp directory (e.g. /tmp/angular-cli-packages-xxx). Since this directory is outside the project tree, npm/pnpm/yarn-classic cannot find the project's .npmrc and falls back to the user-level ~/.npmrc. This causes registry settings defined in the project's .npmrc to be ignored.

Issue Number: #27163

What is the new behavior?

Project configuration files (.npmrc, .yarnrc, pnpm-workspace.yaml) are now copied to the temporary directory before running npm install. This reuses the existing copyConfigFromProject mechanism (previously only enabled for bun) for npm, pnpm, and yarn-classic.

Does this PR introduce a breaking change?

  • Yes
  • No

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a copyConfigFromProject flag to the package manager descriptors to ensure that project-specific configuration files are correctly copied into temporary directories during package acquisition. This change improves support for private registries and custom configurations. I have identified two potential issues: first, the flag is missing from the modern Yarn descriptor, which may lead to inconsistencies; second, including pnpm-workspace.yaml in the configFiles list for pnpm might trigger unintended workspace-related behavior in the isolated temporary environment.

ignoreScriptsFlag: '--ignore-scripts',
ignorePeerDependenciesFlag: '--strict-peer-dependencies=false',
configFiles: ['.npmrc', 'pnpm-workspace.yaml'],
copyConfigFromProject: true,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Enabling copyConfigFromProject for pnpm will cause pnpm-workspace.yaml to be copied into the temporary directory (as it is listed in configFiles on line 238). This might cause pnpm to attempt workspace-related operations in an isolated temporary directory, which could lead to unexpected behavior or errors if the workspace structure is incomplete. Consider if pnpm-workspace.yaml should be removed from the configFiles list if only registry settings from .npmrc are required for temporary package acquisition.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only .npmrc is needed for registry settings. Added a comment explaining the exclusion.
Worth noting that pnpm-workspace.yaml was never actually copied before this change since copyConfigFromProject was disabled for pnpm, so this is not a regression.

@ptu14 ptu14 force-pushed the fix/ng-update-copy-project-npmrc branch from 6aa2cd4 to 7613be7 Compare April 8, 2026 14:19
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Apr 8, 2026
@alan-agius4 alan-agius4 requested a review from clydin April 8, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/cli target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng update ignores project .npmrc registry

2 participants