Repository navigation
Allow relocation of the per-user ~/.nx data root (for example NX_HOME) #37658
christopher-buss
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Description
Since 23.2.0 (#36514), Nx keeps the task cache and the database for each repository in
~/.nx/<id>/{cache,databases}. The root comes fromos.homedir()(packages/nx/src/utils/nx-tmp-dir.ts), and there is no setting to change it.On machines where the home drive is small, this directory can become very large. One repository can use more than 20 GB. Each temporary or test repository also gets its own
<id>folder, and Nx does not remove these folders. Many users keep tool caches on a different drive (for exampleD:\cacheon Windows). They can do this for npm, pnpm, Yarn, uv, Go, and Cargo with an environment variable, but not for Nx.The current options do not solve this:
NX_CACHE_DIRECTORYorNX_WORKSPACE_DATA_DIRECTORYmakes all workspaces use one directory. The database file name does not include the workspace, andnx resetin one workspace deletes the whole directory (nx resetdeletes the wholecacheDirectory, along with files Nx did not put there #37467).NX_CACHE_DIRECTORYturns off the shared worktree cache, which is the benefit of fix(core): share worktree cache under ~/.nx so agent sandboxes can reach it #36514.~/.nxis refused by the ownership check (packages/nx/src/utils/owned-private-dir.ts), so Nx silently falls back to the checkout.Proposed solution
Read an environment variable, for example
NX_HOME, before thehomedir()fallback inresolveHomeTmpDir(). The per-repository<id>layout and the ownership checks stay the same. Only the root changes. On Unix, Nx could also honor$XDG_CACHE_HOME/nxwhen it is set.Alternatives
<id>folders that Nx has not used for N days.All reactions