-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Labels
discussIssues opened for discussions and feedbacks.Issues opened for discussions and feedbacks.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.
Description
- Version: all
- Platform: Windows
- Subsystem: fs
Trying to open a hidden file on Windows in 'w' mode throws EPERM:
> fs.openSync('hidden.txt', 'w')
Error: EPERM: operation not permitted, open 'C:\hidden.txt'
at Object.fs.openSync (fs.js:651:18)
at repl:1:4
at ContextifyScript.Script.runInThisContext (vm.js:44:33)
at REPLServer.defaultEval (repl.js:239:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:433:10)
at emitOne (events.js:120:20)
at REPLServer.emit (events.js:210:7)
at REPLServer.Interface._onLine (readline.js:278:10)
This matches the behavior of Microsoft C runtime library:
#include <cstdio>
#include <cerrno>
int main()
{
FILE* f = fopen("hidden.txt", "w");
if (f) {
puts("success");
} else if (errno == EACCES) {
perror("EACCES");
} else {
perror("something else");
}
}Output if "hidden.txt" is hidden:
EACCES: Permission denied
And it matches the behavior of Python since it purportedly uses _wfopen under the hood:
>>> open("hidden.txt", "w")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: 'hidden.txt'
However, this behavior has caused at least two issues down the road:
- Error: EPERM: operation not permitted, open 'C:\Users\username\.node_repl_history' #5261 (fixed in repl: support hidden history file on Windows #12207)
- Windows: Cannot save hidden files microsoft/vscode#931 (PR submitted in Use r+ with truncation when saving existing files microsoft/vscode#31733)
So, my questions are:
- Does Node.js really have to match CRT's behavior here? Would anything break if it started allowing opening hidden files in 'w' mode?
- If we can't or don't want to "fix" this, do we want to document this behavior, or do we just say "does the same thing CRT does"?
Metadata
Metadata
Assignees
Labels
discussIssues opened for discussions and feedbacks.Issues opened for discussions and feedbacks.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.