nx
nx copied to clipboard
Directories in the .nxignore doesn't prevent nx from scanning them
My situation is that I can't execute any nx run commands because nx scans the whole repository and fails than because it hits a directory in our repository where it is missing the required read permissions. (The mentioned directories are in fact mounted into our database containers. )
Current Behavior
To prevent that I tried to add the mentioned directories to the .nxignore:
.build/**/*
.data/**/*
.data
But nx continued to scan these directories:
$ nx lint
nx run [project][:target][:configuration] [_..]
Run a target for a project
(e.g., nx run myapp:serve:production).
You can also use the infix notation to run a target:
(e.g., nx serve myapp --configuration=production)
You can skip the use of Nx cache by using the --skip-nx-cache option.
Options:
--version Show version number [boolean]
--prod Use the production configuration [boolean] [default: false]
-c, --configuration Target configuration [string]
--project Target project [string]
--output-style Defines how Nx emits outputs tasks logs [string] [choices: "dynamic", "static", "stream", "compact"]
Error: EACCES: permission denied, scandir '/home/yves/Documents/Work/dev3/.data/mongodb/diagnostic.data'
at Object.readdirSync (node:fs:1392:3)
at readdirWithFileTypes (/home/yves/Documents/Work/dev3/node_modules/@nodelib/fs.scandir/out/providers/sync.js:16:33)
at Object.read (/home/yves/Documents/Work/dev3/node_modules/@nodelib/fs.scandir/out/providers/sync.js:10:16)
at SyncReader.scandirSync [as _scandir] (/home/yves/Documents/Work/dev3/node_modules/@nodelib/fs.scandir/out/index.js:18:17)
at SyncReader._handleDirectory (/home/yves/Documents/Work/dev3/node_modules/@nodelib/fs.walk/out/readers/sync.js:28:34)
at SyncReader._handleQueue (/home/yves/Documents/Work/dev3/node_modules/@nodelib/fs.walk/out/readers/sync.js:23:18)
at SyncReader.read (/home/yves/Documents/Work/dev3/node_modules/@nodelib/fs.walk/out/readers/sync.js:15:14)
at SyncProvider.read (/home/yves/Documents/Work/dev3/node_modules/@nodelib/fs.walk/out/providers/sync.js:11:29)
at ReaderSync.walkSync [as _walkSync] (/home/yves/Documents/Work/dev3/node_modules/@nodelib/fs.walk/out/index.js:20:21)
at ReaderSync.dynamic (/home/yves/Documents/Work/dev3/node_modules/nx/node_modules/fast-glob/out/readers/sync.js:13:21) {
errno: -13,
syscall: 'scandir',
code: 'EACCES',
path: '/home/yves/Documents/Work/dev3/.data/mongodb/diagnostic.data'
Expected Behavior
I would expect that nx don't scans ignored directories.
Steps to Reproduce
- Create a new nx-repository
- Create a new directory:
mkdir -p .data - Change the owner to another user:
chown -R OTHER_USER .data - Remove read-permissions for non owners
chmod 600 .data - Add the
.datato your .nxignore - Try to invoke any nx run command.
Environment
$ nx report
> NX Report complete - copy this into the issue template
Node : 16.14.0
OS : linux x64
npm : 8.3.1
nx : 14.1.4
@nrwl/angular : Not Found
@nrwl/cypress : Not Found
@nrwl/detox : Not Found
@nrwl/devkit : Not Found
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : Not Found
@nrwl/js : Not Found
@nrwl/linter : Not Found
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : Not Found
@nrwl/web : Not Found
@nrwl/workspace : Not Found
typescript : 4.3.5
rxjs : 6.6.0
---------------------------------------
Community plugins:
We are experiencing this problem as well. @yveskaufmann Did you find any workaround for the moment?
Same problem here...
+1
+1
@bjoernWahle The solution for me was to move the mounted directories out of the repository.
getting this issue too, moving the mounted directories out of the repository is not really a solution in my case.
seems like the code at https://github.com/nrwl/nx/blob/d2bec05e6caa2f23cebdf021b6988c7ae3c1df8d/packages/nx/src/config/workspaces.ts#L715 causes this; using the original projectGlobPatterns array and adding negative glob patterns to it seems to do the trick, probably have to write a small patch to load ignores from .nxignore and adding it to the ignore parameter of the globSync fn
... or we could just add suppressErrors: true to globSync
same issue. any solution yet?
This has been fixed
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.