-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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.rmdir()
on file (not directory) has "ENOTDIR" on Linux/macOS vs "ENOENT" on Windows
#8797
Comments
What version of Windows? I cannot reproduce on Windows 7 (getting ENOENT, while the docs would suggest ENOTEMPTY to be thrown). |
Well, I was writing this library: https://github.com/jokeyrhyme/idempotent-fs.js And the AppVeyor CI tests fail for related assertions: https://ci.appveyor.com/project/jokeyrhyme/idempotent-fs-js/build/1.0.4/job/sd2snlj4iv5ya0oi I'll run this against versions of Windows I can control today. It's possible that it's file-system related. Maybe there's a difference between FAT32 and NTFS? |
I'd say it's unlikely. Probably more likely that the error is swallowed for files on network drivers. One thing I'd watch out while testing is to try removing a different file than the current script because there might be a active handle (resulting in |
This particular test is deliberately trying to get an error, and I was lazily avoiding the need to create temporary directories. :P But yes, not a great idea generally. |
fs.rmdir()
on file (not directory) has Error result on Linux/macOS, no Error on Windowsfs.rmdir()
on file (not directory) has "ENOTDIR" on Linux/macOS vs "ENOENT" on Windows
@silverwind yeah, after some testing on Windows 10 on an NTFS partition in VirtualBox, I can see that |
Do I understand correctly that the error was always there, just with a different code? |
@silverwind yep. I've updated the Issue title and description. I have found that the error codes are inconsistent. We just have to determine now if this is worth fixing, or if it is minor enough to just ignore. |
@nodejs/platform-windows should we attempt to normalize error codes in this case? The issue here is that Unix has a |
Re-pinging @nodejs/platform-windows. Also: @nodejs/fs. Keep this open? |
I think this is something we could document. |
Note for those coming after... |
fs.rmdir() on the file (not directory) results in different errors on Windows to everything else fixes: nodejs#8797
fs.rmdir() on the file (not directory) results in different errors on Windows to everything else Fixes: #8797 PR-URL: #14323 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
fs.rmdir() on the file (not directory) results in different errors on Windows to everything else Fixes: #8797 PR-URL: #14323 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
fs.rmdir() on the file (not directory) results in different errors on Windows to everything else Fixes: #8797 PR-URL: #14323 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
fs.rmdir() on the file (not directory) results in different errors on Windows to everything else Fixes: #8797 PR-URL: #14323 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
fs.rmdir() on the file (not directory) results in different errors on Windows to everything else Fixes: #8797 PR-URL: #14323 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
fs.rmdir() on the file (not directory) results in different errors on Windows to everything else Fixes: #8797 PR-URL: #14323 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Just noticed an inconsistency between Windows and everything else (why, Windows, why?!) for the
fs.rmdir()
andfs.rmdirSync()
built-in functions.Assuming you save this to a file andnode
it, this file deletes itself on Windows instead of throwing an error as on Linux and macOS.Note that
fs.unlink()
andfs.unlinkSync()
consistently result in Errors if used on a directory's path.Update: the snippet results in an "ENOENT" error on Windows, instead of an "ENOTDIR" error as on Linux / macOS
The text was updated successfully, but these errors were encountered: