-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
chmod doesn't work on Windows #4357
Comments
Sounds reasonable. Should presumably also apply to the soon-to-be added Should the API be that |
Of course, calling I guess it shouldn't be an error to |
I think the way node handles this is that only the user write-bit is honored. In my example |
Currently chmod is a noop on Windows, while analogous functions like chown and umask throw (see denoland#4306). Symlink also currently throws, but that can be implemented on Windows, it just hasn't been done yet (see denoland#815, an implementation was crafted but there were issues that haven't been resolved yet). It's possible to implement chmod in Windows to a limited degree: Rust lets one make Windows files read-only. But the API for how this should work hasn't been settled (see denoland#4357). Until we do implement chmod on Windows, perhaps we should make it throw like the other Windows-unimplemented functions in /cli/ops/fs.rs do? If so, this PR provides an implementation, and fixes tests accordingly. Note that the current implementation of writeFile applies its `mode` option to the file regardless of whether the file was created (and does so using chmod, so it has to be touched by this PR). A forthcoming PR in the denoland#4017 series will make writeFile instead use the new `mode` option in open for new files, and so no longer rely on chmod.
Currently chmod is a noop on Windows, while analogous functions like chown and umask throw (see denoland#4306). Symlink also currently throws, but that can be implemented on Windows, it just hasn't been done yet (see denoland#815, an implementation was crafted but there were issues that haven't been resolved yet). It's possible to implement chmod in Windows to a limited degree: Rust lets one make Windows files read-only. But the API for how this should work hasn't been settled (see denoland#4357). Until we do implement chmod on Windows, perhaps we should make it throw like the other Windows-unimplemented functions in /cli/ops/fs.rs do? If so, this PR provides an implementation, and fixes tests accordingly. Note that the current implementation of writeFile applies its `mode` option to the file regardless of whether the file was created (and does so using chmod, so it has to be touched by this PR). A forthcoming PR in the denoland#4017 series will make writeFile instead use the new `mode` option in open for new files, and so no longer rely on chmod.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I see similar issues in Deno.writeTextFile(). I'm setting the mode to 0o444 (read only). The file is created and filled correctly. But the permissions are wrong. They are "-rw-r--r--" (644) according to git bash, and all permissions for the current use according to Windows file explorer. I should have created a read only file. Barring that I should have gotten an exception or at least seen more details in the documentation. |
It would be nice if |
In Node, the following is observed on Windows:
However, in Deno (v0.36.0) no file mode I tested changed the read-only attribute in any way (including the above two file modes).
From the Node docs:
Windows is not mentioned in the Deno docs.
It would be good if Deno could manipulate the read-only attribute of Windows files and specifically call out Windows quirks in the documentation for chmod.
The text was updated successfully, but these errors were encountered: