Uh oh!
There was an error while loading. Please reload this page.
fs: stop fixing EPERM on Windows - #38810
Conversation
aduh95
commented
May 25, 2021
What should be the semverness of this change? |
RaisinTen
commented
May 26, 2021
Since this is not an API change, I don't think it's going to be semver-major. There is a behavioural change involved, so maybe this is a semver-minor? However, I would consider this to be just a fix as this change aligns rm with what the docs already say:
|
aduh95
left a comment
There was a problem hiding this comment.
LGTM, 69 lines of deleted code, nice!
nit: it reads clearer to me if we let the throw expression inside a if block, feel free to disagree oc
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I think that it makes sense to add a test for this - or at least fix the tests that I added in the previous rmSync fix, so that they don't allow the folder to get deleted when trying to delete it (which I allowed, to get it to pass the tests). It probably makes sense to add a test to rm as well (my test only checks rmSync) |
This comment has been minimized.
This comment has been minimized.
targos
commented
May 26, 2021
@nodejs/fs |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
targos
commented
May 28, 2021
Could it be that the CI runs of this PR are leaving broken directories on Windows hosts? See #38811 (comment) / https://ci.nodejs.org/job/node-test-binary-windows-js-suites/10108/RUN_SUBSET=0,nodes=win10-COMPILED_BY-vs2019/console |
RaisinTen
commented
May 28, 2021
@targos Yes I think one of the CI runs here is to blame, how do we fix it? |
targos
commented
May 28, 2021
/cc @nodejs/build-infra ^ |
richardlau
commented
May 28, 2021
FYI Anyone in @nodejs/build can run https://ci.nodejs.org/job/git-clean-windows/ to clean out the git workspaces on the Windows hosts. (I've just done so.) |
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
RaisinTen
commented
May 29, 2021
@nodejs/build Sorry, I think I broke Windows again: 21:25:07 > git clean -dffx 21:25:07 warning: failed to remove test/.tmp.242/rm-6: Permission deniedWhy don't we run https://ci.nodejs.org/job/git-clean-windows/ at the end of every CI run on the Windows hosts? |
Uh oh!
There was an error while loading. Please reload this page.
aduh95
commented
May 29, 2021
It looks like this also broke non-Windows CI machine setups – all builds made after https://ci.nodejs.org/job/node-test-pull-request/38372/ are red, failing on |
That is right. 😕 |
Maybe we could change the tmpdir |
RaisinTen
commented
May 30, 2021
@Linkgoron Updated tmpdir. PTAL. |
There was a problem hiding this comment.
Do we need extras checks to make sure we're not changing access to a directory outside (e.g. the parent) of the tmpdir?
There was a problem hiding this comment.
Since err comes from rmSync(tmpPath);, the path in err will always be something inside tmpPath, so I don't think we need more checks.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
aduh95
commented
May 31, 2021
It might be just an unlucky coincidence, https://github.com/nodejs/node/actions/workflows/build-windows.yml |
RaisinTen
commented
Jun 16, 2021
👍 @nodejs/tooling Pinging again for review because a week has passed and we didn't get any review yet. |
bcoe
commented
Jun 18, 2021
@RaisinTen with regards to this change, my concern is that the Given that tests are one of the most common places where this helper is likely to be used, are we sure this is a change we want to take? |
The semantics around removing read-only files differs between Windows and Posix.
See: isaacs/rimraf#24 (comment) Removing this will make it impossible for users to remove read-only files on Windows, which is allowed by posix The divergence between Posix and this rimraf implementation on windows, is that on Posix systems, while you can delete read-only files and directories, you may not delete the contents of a read-only directory. I would perhaps be +1 on replicating that behavior, however, the expectation of being able to remove directories on Windows (eg, by deleting them in Explorer) is that a read-only folder may be removed if the user has permission to change its read-only status, and its contents may be removed as well. Thus, the decision was made to keep the workaround as it is. tl;dr - If you remove this EPERM workaround, you will make a lot of windows users unable to delete |
bcoe
commented
Jun 18, 2021
@RaisinTen@isaacs perhaps rather than landing this change, we could land a test that demonstrates initializing an empty git repo, and then uses And then add a comment to our implementation which explains @isaacs' reasoning in detail. |
isaacs
commented
Jun 18, 2021
What problem is this patch aiming to solve? If there isn't a substantive complaint about the functionality as it is, it seems to me like it's changing code to match the documentation, when we ought to be updating the documentation to match what the code has been doing without complaint for 8 years. |
boneskull
left a comment
There was a problem hiding this comment.
I'm -1 on this. It's going to break users for reasons of cross-platform consistency where no such consistency exists in the first place. Better to update docs.
RaisinTen
commented
Jun 19, 2021
If we want to Also, shouldn't we depend on what Libuv does for these kinds of things instead of handling them from inside Node.js? I know that the implementation of a number of functions in Windows users can run
Here too, an initial |
If we want to chmod() and retry deleting folders on Windows when an EPERM occurs, shouldn't we do it from inside rmdir() instead of rimraf? Why keep rm() and rmdir() inconsistent while removing a read only directory on Windows?On my mind when we worked on this feature, was that once you say
It felt okay to have this, while having Windows users can run chmod() before removing .gitMany folks relying on Someone writing a library that generates It creates cruft in tests, and is confusing (you would need to know about this edge case in folder permissions ahead of time to address the issue). Shouldn't we depend on what Libuv does for these kinds of things instead of handling them from inside Node.jsI'm very supportive of removing functionality from Node.js if we can get it upstreamed in libuv 👍 I also think it's perfectly okay to have functionality in Node.js that improves platform ergonomics ... sometimes it's harder to fix things in a lower level, which can be relatively easy to fix a layer of abstraction up. My two centsIf I'm understanding correctly, Node.js' own test suites started leaving Having said this, I'm very supportive of:
|
RaisinTen
commented
Mar 18, 2022
I don't think this is worth the breakage anymore. |
bcoe
commented
Mar 20, 2022
@RaisinTen thanks for being understanding, regarding the tradeoffs discussed in this thread 👍 One thought, we should probably still add a test for deleting |
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: nodejs#38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com>
RaisinTen
commented
Mar 20, 2022
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: #38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: #38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: nodejs#38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: nodejs#42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: #38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: nodejs#38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: nodejs#42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: #38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: #38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: #38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: #38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: #38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Git for Windows creates read-only files inside the .git directory. fs.rm() was built in a way, to work around any EPERM error that can happen while deleting the .git directory by turning the directory into a writable one. This change adds a regression test for that. Refs: isaacs/rimraf#21 Refs: nodejs/node#38810 (comment) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: nodejs/node#42410 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Originally, when
rimraffaced anEPERMon Windows, it would try tochange the file permissions of the entry and attempt to remove it
again. However,
rm -rfdoesn't change any file permissions, sorimrafshouldn't either.
This change also updates
test/common/tmpdir.jsto repeatedly trychanging the file permissions of its contents to
0o777when anEACCESoran
EPERMis faced while attempting to remove them.Signed-off-by: Darshan Sen raisinten@gmail.com