File i/o, case sensitivity and cross-platform behavior #16731
Copy link
Copy link
Closed
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
Description
- Version: 9.0.0
- Platform: 64 bit Windows and Linux present 3.13.0-108-generic docs: changed example in streams for write() after end() #155-Ubuntu SMP Wed Jan 11 16:58:52 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem: fs
So, when using fs commands across platforms, I've noticed some interesting behavior with case sensitivity. On OSes where case sensitivity is not a concern like Windows and OSX, node's file i/o calls work the same with not caring about case sensitivity. Whereas on Linux it does.
For example,
util.promisify(fs.readdir)('./foo/bar.txt').then( files => console.log(file))
and
util.promisify(fs.readdir)('./Foo/bar.txt').then( files => console.log(file))
Will do the same thing on OSX and Windows, however on Ubuntu (which I am using in a production environment), will only see what is actually on the file system. As node aims to be cross-platform it may be beneficial to have the stricter behavior be constant.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
Activity
mscdex commentedon Nov 3, 2017
-1 I would not expect node to perform case-insensitive path lookups on case-sensitive file systems. Not only would it be unexpected, but it could lead to breakage in userland and would probably lead to reduced performance for little benefit.
I do not see this as a cross-platform issue, it is more of a difference in file system behavior. Even on Windows, you can enable case sensitivity for NTFS file systems. Also, the file system used by WSL is case sensitive. What would you do in that case (and WSL is more popular than an explicitly case-sensitive NTFS file system)? Because of this, I do not think it's as simple as saying node should enforce sensitivity one way or the other and/or node should try to smooth over differences in file systems on any given platform, which is way outside the scope of this project.
rjerue commentedon Nov 4, 2017
Yeah, it's not so much a problem, just a quirk in the behavior that I noticed. Often cross-platform things run the same across platforms; this did not. This did not. Sure it is I assume because it actually does calls to the system OS and the OS actually acknowledges if the file or directory is there / what the file or directory is.
Breakage in current codebases is a very significant problem that I see though.
I just didn't know if it was intended behavior or what.
bnoordhuis commentedon Nov 6, 2017
I'll close this out. Issues around case (in)sensitivity have been discussed before and the consensus is that we won't (or even reasonably can) paper over them.