New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
environment variable to override cacheDirectory in nx.json #6629
Labels
Comments
shihabuddin
added a commit
to shihabuddin/nx
that referenced
this issue
Aug 10, 2021
… directory Use the environment variable NX_CACHE_DIRECTORY to set the cache directory. This would override the cache directory set in nx.json. ISSUES CLOSED: nrwl#6629
shihabuddin
added a commit
to shihabuddin/nx
that referenced
this issue
Aug 17, 2021
In 6c16ee0 the environment variable was used while reading from `nx.json`. But in `packages/workspace/src/tasks-runner/cache.ts` the `cacheDirectory` is used without using `readCacheDirectoryProperty`. Now we check the environment variable in `cacheDirectory`, so that the environment variable is always used. ISSUES CLOSED: nrwl#6629
FrozenPandaz
pushed a commit
that referenced
this issue
Aug 18, 2021
In 6c16ee0 the environment variable was used while reading from `nx.json`. But in `packages/workspace/src/tasks-runner/cache.ts` the `cacheDirectory` is used without using `readCacheDirectoryProperty`. Now we check the environment variable in `cacheDirectory`, so that the environment variable is always used. ISSUES CLOSED: #6629
ManojBahuguna
pushed a commit
to ManojBahuguna/nx
that referenced
this issue
Sep 16, 2021
…6746) In 6c16ee0 the environment variable was used while reading from `nx.json`. But in `packages/workspace/src/tasks-runner/cache.ts` the `cacheDirectory` is used without using `readCacheDirectoryProperty`. Now we check the environment variable in `cacheDirectory`, so that the environment variable is always used. ISSUES CLOSED: nrwl#6629
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
Define environment variable - e.g. NX_CACHE_DIRECTORY - that would override the cacheDirectory option in nx.json taskRunnerOptions
Motivation
I would like to keep the nx cache outside of my git worktree as I use git worktree a lot to keep multiple branches ready at the same time and it would be very preferable to shared the cache.
If all developer machines were on the same platform I could set taskRunnerOptions.cacheDirectory to "/tmp/.nxcache" or "/var/cache/nx" but this would not work on WINDOWS.
Being able to override the configuration with an environment variable would solve this problem.
Suggested Implementation
in utilities/cache-directory.ts something like this:
export function readCacheDirectoryProperty(root: string) {
try {
let cacheDir = process.env.NX_CACHE_DIRECTORY;
if (!cacheDir) {
const nxJson = readJsonFile(join(root, 'nx.json'));
cacheDir = nxJson.tasksRunnerOptions.default.options.cacheDirectory;
}
return cacheDir;
} catch (e) {
return undefined;
}
}
Alternate Implementations
The text was updated successfully, but these errors were encountered: