Skip to content

fix(core): keep the cache in the workspace on CI - #36922

Merged
FrozenPandaz merged 6 commits into
masterfrom
disabled-shared-cache-dir-in-ci-5d75da49
Sep 4, 2026
Merged

fix(core): keep the cache in the workspace on CI#36922
FrozenPandaz merged 6 commits into
masterfrom
disabled-shared-cache-dir-in-ci-5d75da49

Conversation

@AgentEnder

@AgentEnder AgentEnder commented Sep 4, 2026

Copy link
Copy Markdown
Member

Current Behavior

Nx 23.2 with Nx Cloud 2026.07.1 fails in the V4 worker because nx/src/utils/workspace-context cannot be found.

The Nx Cloud client bundle installs to join(cacheDir, 'cloud') and resolves a bare nx specifier, which only works by walking up into the workspace's node_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_modules then /node_modules — never the workspace. pnpm shimming masked it in the ocean and nx workspaces.

Expected Behavior

getBundleInstallDefaultLocation installs the bundle under this checkout's own cache directory on CI, so walking up reaches node_modules/nx again.

The constraint is specific to the bundle: it is the only thing stored under cacheDir that gets required. 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 cacheDirectory all 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.

@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 7cab93b
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a9b3ce073fd6300080ac8f1
😎 Deploy Preview https://deploy-preview-36922--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 7cab93b
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a9b3ce00ea8720008817203
😎 Deploy Preview https://deploy-preview-36922--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 68d2e5d

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ✅ Succeeded 8m View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 55s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 19s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-04 22:01:39 UTC

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
AgentEnder force-pushed the disabled-shared-cache-dir-in-ci-5d75da49 branch from c1aa8a9 to 299fa27 Compare September 4, 2026 19:02
@AgentEnder
AgentEnder marked this pull request as ready for review September 4, 2026 19:08
@AgentEnder
AgentEnder requested a review from a team as a code owner September 4, 2026 19:08
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud Bot and others added 4 commits September 4, 2026 20:00
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
FrozenPandaz force-pushed the disabled-shared-cache-dir-in-ci-5d75da49 branch from 8468366 to 68d2e5d Compare September 4, 2026 20:53

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

@FrozenPandaz
FrozenPandaz enabled auto-merge (squash) September 4, 2026 21:56
@FrozenPandaz
FrozenPandaz merged commit d809e1e into master Sep 4, 2026
18 checks passed
@FrozenPandaz
FrozenPandaz deleted the disabled-shared-cache-dir-in-ci-5d75da49 branch September 4, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants