#54180: fix: remove read-only files with fs.rmSync on Windows
Description of Change
A downstream test suite encountered nodejs/node#64374 while upgrading from Electron v43.6.0 to v43.7.1: fs.rmSync fails with EPERM when removing read-only files on Windows.
Node's C++ implementation uses std::filesystem, but libc++ does not clear the Windows read-only attribute before removal as MSVC STL does. Electron builds Node with libc++, exposing this difference from official Node builds.
Backport nodejs/node#64453 (2987a5965f1f) to clear the attribute and retry removal, retaining the upstream regression test.
Fixes #52253.
Note: this patch doesn't let us remove test_account_for_libc_rm_error_on_electron_linux.patch 🤷♂️
CC @deepak1556 as downstream stakeholder
CC @jkleinsc as this week's Node.js roll stakeholder
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - tests are changed or added
- PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, past tense, and no longer than 80 characters.
Release Notes
Notes: Fixed fs.rmSync failing to remove read-only files on Windows.
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron