Skip to content
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

Find command crashes when trying to scan Directories without Permission on Windows #1095

Open
DanielTerletzkiy opened this issue Jun 14, 2022 · 6 comments
Labels
fix Bug/defect, or a fix for such a problem good first issue Windows

Comments

@DanielTerletzkiy
Copy link

Node version (or tell us if you're using electron or some other framework):

v14.17.1

ShellJS version (the most recent version/Github branch you see the bug on):

0.8.5

Operating system:

Windows 10

Description of the bug:

When using the find command, it will throw Error [ShellJSInternalError]: EPERM: operation not permitted, scandir [dir] when it has no permission to access the folder for scanning.
Is there a way to let it ignore this directory and continue scanning?

Example ShellJS command to reproduce the error:

const files = shell.find('.').filter(function (file: string) {
    if (!file.includes('node_modules')) {
        return file.match(/\.git$/);
    }
});
@nfischer
Copy link
Member

Can you share the full error stack?

@nfischer nfischer added fix Bug/defect, or a fix for such a problem Windows labels Jun 18, 2022
@DanielTerletzkiy
Copy link
Author

Of course
In all tests where it was scanning, I checked why these directories could not be scanned, turns out that these are 'Symbolic link files'. Hidden in File Explorer but can be found by using bash with ls command

[1] events.js:352
[1]       throw er; // Unhandled 'error' event
[1]       ^
[1] Error [ShellJSInternalError]: EPERM: operation not permitted, scandir 'C:/Users/Daniel.Terletzkiy/Anwendungsdaten'
[1]     at Object.readdirSync (fs.js:1043:3)
[1]     at GlobSync._readdir (C:\Users\Daniel.Terletzkiy\PhpstormProjects\ultira\node_modules\glob\sync.js:288:46)
[1]     at GlobSync._readdirInGlobStar (C:\Users\Daniel.Terletzkiy\PhpstormProjects\ultira\node_modules\glob\sync.js:267:20)
[1]     at GlobSync._readdir (C:\Users\Daniel.Terletzkiy\PhpstormProjects\ultira\node_modules\glob\sync.js:276:17)
[1]     at GlobSync._processGlobStar (C:\Users\Daniel.Terletzkiy\PhpstormProjects\ultira\node_modules\glob\sync.js:350:22)
[1]     at GlobSync._process (C:\Users\Daniel.Terletzkiy\PhpstormProjects\ultira\node_modules\glob\sync.js:130:10)
[1]     at GlobSync._processGlobStar (C:\Users\Daniel.Terletzkiy\PhpstormProjects\ultira\node_modules\glob\sync.js:383:10)
[1]     at GlobSync._process (C:\Users\Daniel.Terletzkiy\PhpstormProjects\ultira\node_modules\glob\sync.js:130:10)
[1]     at new GlobSync (C:\Users\Daniel.Terletzkiy\PhpstormProjects\ultira\node_modules\glob\sync.js:45:10)
[1]     at Function.globSync [as sync] (C:\Users\Daniel.Terletzkiy\PhpstormProjects\ultira\node_modules\glob\sync.js:23:10)
[1] Emitted 'error' event on process instance at:
[1]     at emitUnhandledRejectionOrErr (internal/event_target.js:578:11)
[1]     at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:403:9)
[1]     at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26) {
[1]   errno: -4048,
[1]   syscall: 'scandir',
[1]   code: 'EPERM',
[1]   path: 'C:/Users/Daniel.Terletzkiy/Anwendungsdaten'
[1] }
[1] node express/Server.js exited with code 1

@Morsmalleo
Copy link

Getting the same problem with my own application, any help on this???

@nfischer
Copy link
Member

Hmm looks like it's crashing inside the glob module. Unfortunately I would need some help debugging this since I don't regularly use Windows.

@PrathamLalwani
Copy link

I can help out @nfischer. Is there specific information you are looking for?

@nfischer
Copy link
Member

If you can still repro this: does upgrading the glob package workaround the crash? Is there a spot in shelljs code where we can meaningfully catch this crash and still have partial results of the wildcard expansion?

I understand we cannot get results from directories which we don't have permission to access, but ideally we would want the wildcard to expand to include all the folders we can access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug/defect, or a fix for such a problem good first issue Windows
Projects
None yet
Development

No branches or pull requests

4 participants