-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs: stop fixing EPERM on Windows #38810
fs: stop fixing EPERM on Windows #38810
Conversation
What should be the semverness of this change? |
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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
@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.
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
|
@targos Yes I think one of the CI runs here is to blame, how do we fix it? |
/cc @nodejs/build-infra ^ |
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.
This comment has been minimized.
This comment has been minimized.
@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 denied Why don't we run https://ci.nodejs.org/job/git-clean-windows/ at the end of every CI run on the Windows hosts? |
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 |
@Linkgoron Updated tmpdir. PTAL. |
test/common/tmpdir.js
Outdated
|
||
if (errCode === 'EACCES' || errCode === 'EPERM') { | ||
const surroundingDir = path.join(errPath, '..'); | ||
fs.chmodSync(surroundingDir, 0o777); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
It might be just an unlucky coincidence, https://github.com/nodejs/node/actions/workflows/build-windows.yml |
Not necessarily him, but I would feel much more comfortable with this if it's approved by someone from the tooling team. |
👍 @nodejs/tooling Pinging again for review because a week has passed and we didn't get any review yet. |
@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 |
@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. |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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:
|
I don't think this is worth the breakage anymore. |
@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>
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
rimraf
faced anEPERM
on Windows, it would try tochange the file permissions of the entry and attempt to remove it
again. However,
rm -rf
doesn't change any file permissions, sorimraf
shouldn't either.
This change also updates
test/common/tmpdir.js
to repeatedly trychanging the file permissions of its contents to
0o777
when anEACCES
oran
EPERM
is faced while attempting to remove them.Signed-off-by: Darshan Sen raisinten@gmail.com