-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Bun throws error when copying file to a folder that does not exist #11260
Comments
Confirmed, @birkskyum. I have the same issue (used Bun v1.1.9 on Windows 11): |
the error occurs when working with nitropack (vinxi/nitro component). something is wrong with fs.promises.cp(). this happens even if all copies are executed sequentially (for (...) { await ... }) |
Smaller reproduce import { promises } from 'node:fs';
const src = 'newFile.txt';
const folder = 'folder-not-exist'
const dst = `${folder}/${src}`;
await promises.writeFile(src, 'A'.repeat(131073))
await promises.rm(folder, { recursive: true, force: true })
await promises.cp(src, dst);
console.log('Success') ❯ bun test.js
ENOENT: No such file or directory
errno: -2
syscall: "copyfile"
path: "newFile.txt"
Bun v1.1.10 (macOS arm64)
❯ node test.js
Success If this works for you, you can try increasing the repetition value |
Now that it's much more narrowed down - What would be a more accurate title for this issue? Any pointers to wether the issue is in .repeat() or in the .writeFile? |
I didn't use .repeat when I got the error (unless SolidStart is using it internally, which I doubt.). |
If folder doesn't exist, cp in node will create folder, but bun won't. import { promises } from 'node:fs';
const src = 'newFile.txt';
const folder = 'folder-not-exist'
const dst = `${folder}/${src}`;
await promises.writeFile(src, 'A'.repeat(131073))
await promises.rm(folder, { recursive: true, force: true })
await promises.mkdir(folder);
await promises.cp(src, dst);
console.log('Success') Bun run this => Success |
Bun error occurs if you need to copy a |
So @birkskyum, new issue title could be, "Bun throws error when copying large file to a folder that does not exist"? |
Thanks to @sirenkovladd for supplying the "smaller reproduce"! |
On my computer, this also causes the error, so I don't think the file size is the issue. |
bun/src/js/node/fs.promises.ts Line 4 in 99b979e
bun/src/js/node/fs.promises.ts Lines 97 to 109 in 99b979e
Set any option that makes this function return the js fallback ported from node will make the program succeed. import { promises } from "node:fs"
const src = "newFile.txt"
const folder = "folder-not-exist"
const dst = `${folder}/${src}`
await promises.writeFile(src, "A")
await promises.rm(folder, { recursive: true, force: true })
await promises.cp(src, dst, { dereference : true })
await promises.rm(folder, { recursive: true, force: true })
await promises.cp(src, dst, { preserveTimestamps: true })
await promises.rm(folder, { recursive: true, force: true })
await promises.cp(src, dst, { verbatimSymlinks: true })
console.log("Success") So I think the problem is in zig's implementation. |
Nice find with the repro @Huliiiiii . Seems like some zig expertise is due at this point. cc @paperdave |
What version of Bun is running?
1.1.10-canary.1+cc0bce62e
What platform is your computer?
Darwin 23.4.0 arm64 arm
What steps can reproduce the bug?
I experience that I can make a clean
basic
example (bun create solid), dump a few files in the public folder, like .glb 3d models, and then thebun --bun run build
command will break with:It's worth noting that it's not a requirement to use these files anywhere in the code for this to break
What is the expected behavior?
When running
pnpm run build
or npm, then the build completesWhat do you see instead?
No response
Additional information
Related to
The text was updated successfully, but these errors were encountered: