fix(core): keep the cache in the workspace on CI - #36922
Merged
Merged
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit 68d2e5d
☁️ Nx Cloud last updated this comment at |
The Nx Cloud client bundle installs under `cacheDir` and requires bare `nx`, which resolves only by walking up into the workspace's node_modules. Since the cache moved to the shared `~/.nx/<id>` root the DTE V4 worker fails with `nx/src/utils/workspace-context` not found. pnpm shimming masked it in the ocean and nx workspaces. `computeSharedDataLocation` answers `none` on CI, so the cache and the project graph database stay at `<workspaceRoot>/.nx`. The check goes in the one predicate both kinds follow rather than in `cacheDir` alone, so the cache and the database cannot end up in different scopes. Updates the docs that named `~/.nx/<id>/cache` as the unconditional default, including the callout telling readers to repoint their CI cache step at `~/.nx`.
AgentEnder
force-pushed
the
disabled-shared-cache-dir-in-ci-5d75da49
branch
from
September 4, 2026 19:02
c1aa8a9 to
299fa27
Compare
AgentEnder
marked this pull request as ready for review
September 4, 2026 19:08
The client bundle `require`s a bare `nx` specifier, which resolves only by walking up into the workspace's node_modules, so it cannot follow `cacheDir` -- that is shared per-user and lives outside the checkout. Reverts the CI-scoped cache carve-out and fixes the resolution constraint where it lives instead, so the bundle is reachable on every environment and every cache configuration rather than only on CI. NXC-4944
The bundle resolves a bare `nx` by walking up into node_modules, which the shared per-user root cannot reach. On CI it now follows this checkout's own cache directory; off CI the shared root is kept, so one download still serves every checkout of the workspace. NXC-4944
`getBundleInstallDefaultLocation` already returns the directory the version subdirectories sit in, so appending `cloud` pointed one level too deep and `rmSync` silently no-opped on the missing path. `nx reset` never removed the bundle in any configuration.
FrozenPandaz
force-pushed
the
disabled-shared-cache-dir-in-ci-5d75da49
branch
from
September 4, 2026 20:53
8468366 to
68d2e5d
Compare
Contributor
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
FrozenPandaz
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
Nx 23.2 with Nx Cloud 2026.07.1 fails in the V4 worker because
nx/src/utils/workspace-contextcannot be found.The Nx Cloud client bundle installs to
join(cacheDir, 'cloud')and resolves a barenxspecifier, which only works by walking up into the workspace'snode_modules. Since the cache moved to the shared per-user root, that path is~/.nx/<id>/cache/cloud, and walking up from it reaches~/node_modulesthen/node_modules— never the workspace. pnpm shimming masked it in theoceanandnxworkspaces.Expected Behavior
getBundleInstallDefaultLocationinstalls the bundle under this checkout's own cache directory on CI, so walking up reachesnode_modules/nxagain.The constraint is specific to the bundle: it is the only thing stored under
cacheDirthat getsrequired. Everything else there — task artifacts, terminal outputs, the graph database — is data, and has no resolution requirement. So the fix sits at the one line that has the constraint rather than at the cache-location decision, and the cache itself is unchanged.Off CI the shared per-user root is kept, so a single download still serves every checkout of the workspace.
Related Issue(s)
NXC-4944
Fixes #
Migration coverage
None. No configuration, path or public API changes: the cache, the workspace-data directory and
cacheDirectoryall behave exactly as they do today. The only path that moves is the Nx Cloud client bundle's install location on CI, which is re-downloaded when absent.