fs.copyFile fails if source is readonly and target is a CIFS volume
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
Version
v22.21.1
Platform
Linux a7f6d3be6434 5.15.158-2-pve #1 SMP PVE 5.15.158-2 (2024-07-26T13:11Z) x86_64 Linux
Docker: Alpine release 3.22.2
Subsystem
fs
What steps will reproduce the bug?
Hi,
Copying sample.docx fails with EPERM because the source is read-only and the destination is a CIFS share.
Probably related to:
https://github.com/nodejs/node/issues/37284
https://github.com/libuv/libuv/issues/3117
https://github.com/nodejs/node/issues/44261
How often does it reproduce? Is there a required condition?
100% reproducible
What is the expected behavior? Why is that the expected behavior?
/mnt/smb is a CIFS-mounted volume.
sample.docx is a file with read-only permissions for the user running the below code.
Code
import {copyFile} from "fs/promises";
const src = "./sample.docx";
const dest = "/mnt/smb/sample.docx";
await copyFile(src, dest);
console.log("File copied successfully");
The fs.copyFile should be able to succeed in copying the file as long as the destination folder is writable.
What do you see instead?
Error
node:internal/modules/run_main:123
triggerUncaughtException(
^
[Error: EPERM: operation not permitted, copyfile './sample.docx' -> '/mnt/smb/sample.docx'] {
errno: -1,
code: 'EPERM',
syscall: 'copyfile',
path: './sample.docx',
dest: '/mnt/smb/sample.docx'
}
Additional information
Works with no error
cp ./sample.docx /mnt/smb/sample.docx
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the fs/promises copyFile entry point and reproduce the failure on Linux with a read-only source and writable CIFS destination. Compare Node’s behavior with cp, then read the linked Node.js and libuv issues. Done means copyFile succeeds under the stated permissions without the reported EPERM error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, linux, node.js
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100