fix(devkit): prevent double install in generators for TS solution workspaces#34891
fix(devkit): prevent double install in generators for TS solution workspaces#34891FrozenPandaz merged 9 commits intomasterfrom
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…on workspaces The library generators for @nx/js, @nx/node, and @nx/vue were passing `alwaysRun=true` to `installPackagesTask` in TS solution workspaces, which bypasses the package.json cache and causes a redundant second install. The init generator already triggers an install via `addDependenciesToPackageJson`, so the cache correctly deduplicates when `alwaysRun` is not set.
80dac56 to
4bc1715
Compare
|
View your CI Pipeline Execution ↗ for commit 42c254b
☁️ Nx Cloud last updated this comment at |
… already ran When alwaysRun is true and install already executed this generator cycle (cache is set), skip the redundant install. The previous install already picked up all filesystem changes including workspace config updates needed for symlinks.
…brary generators The library generators need ensureInstall=true for the second+ library case where no deps change but install must run for symlinks. Renamed parameter since it no longer always runs — it skips when install already ran this cycle.
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:
We investigated the maven-batch-runner:_package failure and determined it is caused by a corrupted Nx database on the CI runner ("Database file exists but has no metadata table"), which is unrelated to the devkit changes in this PR. This error does not appear on the master branch and requires an environment reset (nx reset) to resolve rather than any code change.
No code changes were suggested for this issue.
Trigger a rerun:
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
In TS solution workspaces, library generators pass
alwaysRun=truetoinstallPackagesTaskto ensure symlinks are created for new packages. However, when the init generator already triggered an install (viaaddDependenciesToPackageJson), thealwaysRunflag bypasses the cache and forces a redundant second install.Expected Behavior
Only a single install should run per generator invocation. If install already ran this cycle, subsequent
ensureInstallcalls should be skipped since the previous install already picked up all filesystem changes (includingpnpm-workspace.yamlupdates for symlinks).Fix
Renamed
alwaysRuntoensureInstallininstallPackagesTaskand simplified the install condition:This handles both cases:
ensureInstallcallback sees install already ran → skips. One install.ensureInstallcallback sees no prior install → runs. One install.Related Issue(s)