-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
.gitignore: true
makes globby crash on directory with bad read permissions
#254
Comments
I would say this is a bug. The |
Yes, I agree. Ignored und readable directories would be a sensible default behavior. |
I started looking into this a bit. To me the best way to fix this would be to pass https://github.com/sindresorhus/globby/blob/main/ignore.js#L68 That even seems to be intented according to the fast-glob README.
However, I am not sure if this has unwanted side effects such as other errors that users would want to know about not being reported. Also, this might mean that it's worth mentioning in the Do you think this would be a solution worth implementing or not? The actual implementation could probably be as simple as changing the default value of const normalizeOptions = (options = {}) => ({
cwd: toPath(options.cwd) || process.cwd(),
- suppressErrors: Boolean(options.suppressErrors),
+ suppressErrors: options.suppressErrors === false ? false : true, // make sure supressErrors is aways true unless explicitly passed as false
deep:
typeof options.deep === "number" ? options.deep : Number.POSITIVE_INFINITY,
}); |
👍 |
It seems like the underlying issue here is more that globby indiscriminately recursively searches for .gitignore files everywhere before doing anything else, which seems to mean it scans through all sorts of directories that are deeply nested inside dirs that are gitignored, which eem like a large perf issue in addition to causing this read permission error (i don't want it to scan 1 million files in my gitignored node_modules folder just because there might be a gitignore file somewhere in there |
In our project we have a folder under the root folder which is .gitignored and used by a docker image to write to database data.
Since it's running inside a Docker container the directory has a different owner and the files can not be read by the user outside of the docker container.
When running globby with the
gitignore: true
option it crashes.Steps to reproduce
The last line crashes with an error like this:
Setting
gitignore: false
makes the error go awayIt's not globby's fault that it can't read the directory. Would you consider adding a way to alter globby's behavior in this case though? For example with an option like
unreadable: 'skip'
which would simply skip directories that can't be read.PS the whole thing came up when using
knip
which is using globby under the hood webpro-nl/knip#172The text was updated successfully, but these errors were encountered: