-
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
doc: add note about path.basename on Windows #35065
Conversation
cc @nodejs/platform-windows |
Is this behavior that we want to change? It would make sense to me to do so, given the filesystem’s behavior |
@addaleax I was surprised by this behavior in Node.js, too. It turns out to be a complex problem. Technically, it's not filesystem behavior. NTFS, the standard file system on Windows, implements case-sensitive names. I never tried this, but apparently Linux code within the Windows Subsystem for Linux will be able to utilize case-sensitivity in the host system's file system. So on the filesystem level, two files with the same name, but different capitalization, can exist. However, outside of WSL, Windows cannot handle case-sensitive names, and will hide one of those files from applications. (This causes some horrific issues, e.g., microsoft/WSL#3394, microsoft/WSL#3356). This makes it virtually impossible for Windows applications to access one of those files. I think Win32 applications would only see one of the two files, and would be unable to access the other. But if that is true, then what happens if a Win32 application moves or deletes such a file? Would the other file still exist, and now be accessible? I have no idea, it's a terrible mess. If we change the existing API in Node.js, it would probably have to be semver-major, so landing the warning earlier might be a good idea. Another issue might be that Windows simply doesn't have an equivalent to |
@tniessen I’m fully agreeing :) I’m also okay with documenting this now and changing it in a semver-major update. |
@@ -87,6 +87,19 @@ path.basename('/foo/bar/baz/asdf/quux.html', '.html'); | |||
// Returns: 'quux' | |||
``` | |||
|
|||
Although Windows usually treats file names, including file extensions, in a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same is true on macOS. I'm not sure this is a Windows-specific thing. Do we want to change this note to be for all operating systems that treat file names as case-insensitive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, maybe it's more of an issue for Windows (since macOS users are kind of used to things being wonky in this regard, whereas Windows users may have a more consistent "paths are case-insensitive" experience)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware of this on macOS. Reading up on it, it seems that this is not an OS thing, but a file system thing on macOS? As in, their defautl fs is case-insensitive, but the OS also supports case-sensitive file systems? That would be a subtle difference to Windows.
We can surely adapt the note if it makes sense. I have absolutely no experience with macOS, so I'd be happy about suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine leaving the note as-is and updating can happen later if appropriate. But in case someone wants to pitch in.... @nodejs/platform-macos @nodejs/documentation
d9983d9
to
a03e15f
Compare
Landed in a03e15f |
PR-URL: nodejs#35065 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: #35065 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: #35065 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: nodejs#35065 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
As usual, Windows makes everything difficult. This adds a note to
path.basename
about its behavior on Windows.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes