Version
No response
Platform
Subsystem
No response
What steps will reproduce the bug?
Use fs.rmSync on a read-only file on Windows.
How often does it reproduce? Is there a required condition?
Note, this issue appears to only exhibit in Electron, but that is due to our specific build configuration (more at the bottom of this issue).
Downstream issue: electron/electron#52253
What is the expected behavior? Why is that the expected behavior?
Read-only files should be able to be removed with rmSync. This has worked previously.
What do you see instead?
As per downstream issue, the call fails with EPERM.
Additional information
Since #53617, the implementation for fs.rmSync has been written in C++ (specifically using std::filesystem::remove). However, depending on the C++ stdlib being used, this leads to divergent behavior.
- The MSVC STL, used by official Node builds, specifically includes code to support the removal of read-only files with
filesystem::remove.
libc++, currently, does not have such code and uses an API that does not support the removal of read-only files.
Electron uses libc++ to build Node, so it encounters this divergent behavior. Should Node handle this inconsistency inside RmSync, or should libc++ be aligned with the behavior of the MSVC STL?
Version
No response
Platform
Subsystem
No response
What steps will reproduce the bug?
Use
fs.rmSyncon a read-only file on Windows.How often does it reproduce? Is there a required condition?
Note, this issue appears to only exhibit in Electron, but that is due to our specific build configuration (more at the bottom of this issue).
Downstream issue: electron/electron#52253
What is the expected behavior? Why is that the expected behavior?
Read-only files should be able to be removed with
rmSync. This has worked previously.What do you see instead?
As per downstream issue, the call fails with
EPERM.Additional information
Since #53617, the implementation for
fs.rmSynchas been written in C++ (specifically usingstd::filesystem::remove). However, depending on the C++ stdlib being used, this leads to divergent behavior.filesystem::remove.libc++, currently, does not have such code and uses an API that does not support the removal of read-only files.Electron uses
libc++to build Node, so it encounters this divergent behavior. Should Node handle this inconsistency insideRmSync, or shouldlibc++be aligned with the behavior of the MSVC STL?