You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs.copyFile fails if source is readonly and target is a WSL volume #44261
Is the file in question read protected by the operating system? If the operating system has marked a file as read protected, such that it is locked by an underlying operating system process Node will not be able to perform the necessary fs.open method on the file to access the file contents. You will not see this very often on files you, as a user or administrator, own. However, it will happen on some files at the file system root, in system32, file associated with regedit, and so forth. You should still be able to see these files with fs.readdir and fs.stat though.
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.
This is still reproducible on Node.js v24.19.0 with current WSL2. Unlike the original report, the source file is not read-only and Docker is not involved.
C:\ on /mnt/c type 9p (rw,noatime,aname=drvfs;path=C:\;uid=0;gid=0;symlinkroot=/mnt/,cache=0x5,access=client,msize=65536,trans=fd,rfd=6,wfd=6)
Reproduction
The source is on the native WSL filesystem and has mode 0644. The destination is a writable directory under /mnt/c.
constfs=require("node:fs");fs.copyFileSync("/home/james/repositories/isaac-run-timer/node_modules/isaacscript/isaacscript-watcher/resources/gfx/logo.png","/mnt/c/Program Files (x86)/Steam/steamapps/common/The Binding of Isaac Rebirth/mods/copyfile-repro.png",);
Result:
Error: EPERM: operation not permitted, copyfile
The destination directory is writable and its Windows ACL grants my user full control. These operations succeed:
fs.writeFile() to the same destination
GNU cp between the same source and destination
Bun's fs.copyFile() implementation
A direct permission change on a newly created destination file fails:
$ stat -c '%a' /mnt/c/.../probe777
$ chmod 0644 /mnt/c/.../probechmod: Operation not permitted
$ echo$?1
This appears to be a different remaining case from #56248. That issue fixed futimens() failures on CIFS/SMB. Node v24.19.0 contains that fix.
In the current libuv uv__fs_copyfile() implementation, an EPERM from fchmod() is ignored only when uv__is_cifs_or_smb(dstfd) succeeds. WSL's /mnt/c is reported as filesystem type 9p, so the error remains fatal even though the file data can be copied successfully and Unix mode preservation is not supported by this mount.
Could this issue be reopened, or should the fchmod() handling be moved to libuv with 9p/WSL included among the filesystems where permission preservation is best-effort?
Activity
fix(cli): copy readonly file in WSL system
prettydiff commentedon Aug 19, 2022
Is the file in question read protected by the operating system? If the operating system has marked a file as read protected, such that it is locked by an underlying operating system process Node will not be able to perform the necessary
fs.openmethod on the file to access the file contents. You will not see this very often on files you, as a user or administrator, own. However, it will happen on some files at the file system root, in system32, file associated with regedit, and so forth. You should still be able to see these files withfs.readdirandfs.statthough.See also:
juanrgm commentedon Aug 19, 2022
But this it works:
github-actions commentedon Jun 25, 2026
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
github-actions commentedon Jul 26, 2026
This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.
Zamiell commentedon Sep 3, 2026
This is still reproducible on Node.js v24.19.0 with current WSL2. Unlike the original report, the source file is not read-only and Docker is not involved.
Environment
The Windows drive is mounted as 9p:
Reproduction
The source is on the native WSL filesystem and has mode
0644. The destination is a writable directory under/mnt/c.Result:
The destination directory is writable and its Windows ACL grants my user full control. These operations succeed:
fs.writeFile()to the same destinationcpbetween the same source and destinationfs.copyFile()implementationA direct permission change on a newly created destination file fails:
This appears to be a different remaining case from #56248. That issue fixed
futimens()failures on CIFS/SMB. Node v24.19.0 contains that fix.In the current libuv
uv__fs_copyfile()implementation, anEPERMfromfchmod()is ignored only whenuv__is_cifs_or_smb(dstfd)succeeds. WSL's/mnt/cis reported as filesystem type9p, so the error remains fatal even though the file data can be copied successfully and Unix mode preservation is not supported by this mount.Could this issue be reopened, or should the
fchmod()handling be moved to libuv with 9p/WSL included among the filesystems where permission preservation is best-effort?