Repository navigation
fix(@angular/cli): isolate temporary package installations from parent Yarn workspace - #33975
Conversation
There was a problem hiding this comment.
Code Review
This pull request ensures that when using Yarn, an empty yarn.lock is written to the temporary directory to prevent Yarn modern from traversing up the directory tree. It also writes a default .yarnrc.yml with nodeLinker: node-modules if no existing Yarn configuration is copied. Feedback on the changes highlights a potential issue where copiedYarnConfig is set to true before the configuration file is successfully written. If the write operation fails, the fallback configuration will not be written; moving the flag assignment after the write operation resolves this.
…t Yarn workspace When installing a temporary CLI package during update command execution, the temporary directory is placed within the project tree (e.g. under node_modules). When using Yarn modern (v2+), Yarn searches upward for a yarn.lock file to locate the project root. Upon finding the parent project's yarn.lock, Yarn detects that the temporary directory contains a package.json but is not a declared workspace member, causing yarn add to fail with a Usage Error. To resolve this, an empty yarn.lock file is written to the temporary directory when the package manager is Yarn modern. This creates a project boundary that prevents upward workspace traversal and ensures Yarn treats the directory as an independent project. Additionally, if the parent project does not define a .yarnrc.yml or .yarnrc.yaml, a default configuration specifying 'nodeLinker: node-modules' is written to ensure packages are installed into node_modules rather than PnP. Fixes angular#33972
203eec1 to
b4fd640
Compare
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When installing a temporary CLI package during update command execution, the temporary directory is placed within the project tree (e.g. under node_modules). When using Yarn modern (v2+), Yarn searches upward for a yarn.lock file to locate the project root. Upon finding the parent project's yarn.lock, Yarn detects that the temporary directory contains a package.json but is not a declared workspace member, causing yarn add to fail with a Usage Error.
To resolve this, an empty yarn.lock file is written to the temporary directory when the package manager is Yarn modern. This creates a project boundary that prevents upward workspace traversal and ensures Yarn treats the directory as an independent project. Additionally, if the parent project does not define a .yarnrc.yml or .yarnrc.yaml, a default configuration specifying 'nodeLinker: node-modules' is written to ensure packages are installed into node_modules rather than PnP.
Fixes #33972