-
Notifications
You must be signed in to change notification settings - Fork 30k
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
fs.existsSync
returns wrong value on windows if there are no permissions on the given file
#17921
Comments
I have a similar issue where |
let me to see your code |
Perhaps the documentation could be improved (I'll add the label) but The difference is that You might get better results with |
Following the code I use: console.log('bin')
console.log(bin)
console.log('fs.existsSync(bin)')
console.log(fs.existsSync(bin))
try {
console.log('fs.accessSync(bin)')
console.log(fs.accessSync(bin))
} catch (error) {
console.log('-')
}
while (true) { } This is the output:
I put a Any idea? |
@jaulz That's probably some ACL or permissions issue. The directory is there, it's just inaccessible. |
@bnoordhuis not sure... I cannot even find that folder via command nor via explorer. |
I am the reporter of this issue, but I accidentally deleted my account. @bnoordhuis So, this actually works as intended? Ok, then it would be a good idea to mention it somewhere in the doc. Or, even better, change the behavior of @Johnsavadkuhi What does your thumbs down mean: you cannot reproduce the issue, or you disagree that this issue should be considered as a bug? "Let me to see your code" - my code or @jaulz's code? |
In this case |
Yes, see #4679 - Windows CI issue. |
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: nodejs#17921 # Conflicts: # lib/fs.js
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: nodejs#17921 PR-URL: nodejs#18618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: #17921 PR-URL: #18618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: #17921 Backport-PR-URL: #19654 PR-URL: #18618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: nodejs#17921 PR-URL: nodejs#18618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
I'm using NodeJS v11.10.0 on Windows 10 and having the same issue: existsSync says a file does not exist but it does and I do have permissions on it. What to do? |
@cawoodm you probably want to either use There is no guarantee that the file does not exist if |
Oops, I think my problem was with backslashes in the path |
Sorry to comment on a closed issue but I'm seeing the same thing. OS: Windows 10 The file in question is Calling
calling |
Finally got to the bottom of this. Windows has to have the extension of the file in order to check that it exists so |
this is really a stupid language |
Steps to reproduce the issue
1.txt
)fs.existsSync('1.txt')
What is the expected behavior
The file exists (and it is also listed if you
readdirSync
it's parent directory), so the return value should betrue
.What went wrong
The return value is
false
, like the file doesn't exist. If it is working as intended, then consider this issue as a feature request. However, if you're not aware of this behavior, then I'm pretty sure it is a bug.The text was updated successfully, but these errors were encountered: