Title: `fs.rmSync` cannot remove read-only files on Windows when Node is built with `libc++` · Issue #64374 · nodejs/node · GitHub
Open Graph Title: `fs.rmSync` cannot remove read-only files on Windows when Node is built with `libc++` · Issue #64374 · nodejs/node
X Title: `fs.rmSync` cannot remove read-only files on Windows when Node is built with `libc++` · Issue #64374 · nodejs/node
Description: 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 E...
Open Graph Description: 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,...
X Description: 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,...
Opengraph URL: https://github.com/nodejs/node/issues/64374
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`fs.rmSync` cannot remove read-only files on Windows when Node is built with `libc++`","articleBody":"### Version\n\n_No response_\n\n### Platform\n\n```text\n\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\nUse `fs.rmSync` on a read-only file on Windows.\n\n### How often does it reproduce? Is there a required condition?\n\nNote, this issue appears to only exhibit in Electron, but that is due to our specific build configuration (more at the bottom of this issue).\n\nDownstream issue: https://github.com/electron/electron/issues/52253\n\n### What is the expected behavior? Why is that the expected behavior?\n\nRead-only files should be able to be removed with `rmSync`. This has worked previously.\n\n### What do you see instead?\n\nAs per downstream issue, the call fails with `EPERM`.\n\n### Additional information\n\nSince https://github.com/nodejs/node/pull/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.\n\n1. [The MSVC STL, used by official Node builds, specifically includes code to support the removal of read-only files with `filesystem::remove`.](https://github.com/microsoft/STL/pull/1559/changes)\n2. [`libc++`, currently, does not have such code and uses an API that does not support the removal of read-only files.](https://github.com/llvm/llvm-project/blob/2b26ee6e790574e05c3c9a562bc37897daf0f384/libcxx/src/filesystem/posix_compat.h#L238-L246)\n\nElectron 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?","author":{"url":"https://github.com/nmggithub","@type":"Person","name":"nmggithub"},"datePublished":"2026-07-08T21:10:31Z","url":"https://github.com/nodejs/node/issues/64374"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a798a07e-817a-cebf-205c-1104e08312b4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6F8:1E2F2A:729C1F:9B7C33:6AED2AC4 |
| html-safe-nonce | 3663c602a3ff0bf22621490d660e1cd8fbf27ee85e0edda6ca3c709b9a644e5e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkY4OjFFMkYyQTo3MjlDMUY6OUI3QzMzOjZBRUQyQUM0IiwidmlzaXRvcl9pZCI6IjM2NTM2MDIzMzU0NDgxODE0NDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 09da22bebd7194a9a817d4ba1a7932e932deea9f418b590b2f05f2f51d24b4c6 |
| hovercard-subject-tag | issue:4841123411 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/64374/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e91ea4a40d35d37c8c8c849df41f1cb6212ce1c9a0b9b99b41803b46260da89c/nodejs/node/issues/64374 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e91ea4a40d35d37c8c8c849df41f1cb6212ce1c9a0b9b99b41803b46260da89c/nodejs/node/issues/64374 |
| og:image:alt | 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,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nmggithub |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 98b41fa4b5635ceb45a4c54320fced73817ff290 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width