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
cpSync fails with ENOENT when copying symlinks into non-existent directories #28997
Title: cpSync fails with ENOENT when copying symlinks into non-existent directories
cpSync with recursive: true fails when the source is a symlink and the destination's parent directory doesn't exist. Regular files work fine in the same scenario.
ENOENT: no such file or directory, copyfile 'link.md'
Works fine with Node 25. Also works in Bun if you pre-create the parent dir, or pass dereference: true (which forces the JS fallback path).
Cause
The native Zig implementation in _copySingleFileSync (node_fs.zig) already handles ENOENT for regular files by creating parent directories and retrying. The symlink code paths skip this:
macOS (~L6296): calls copyfile() with COPYFILE_NOFOLLOW_SRC, returns immediately on error
Linux (~L6410): calls symlink(src, dest) directly, no parent dir creation
The JS fallback (cp-sync.ts) doesn't have this problem because checkParentDir() runs for all source types before dispatching.
Version
Bun 1.3.11, macOS 15.5 (arm64). Likely affects all platforms.
🔄 Rebased onto main. Main refactored the Linux symlink path into a _cpSymlink helper (that resolves relative link targets against dirname(src), matching Node) and added a FreeBSD path using the same helper. The rebase conflict was in node_fs.zig; resolved by wrapping the _cpSymlink calls on Linux and FreeBSD with the same ENOENT → makePath → retry fallback I already had for the macOS copyfile and Windows CreateSymbolicLinkW branches.
Gate:
stashed (base commit, no fix): 0 pass / 2 fail, ENOENT: no such file or directory, symlink at the cpSync calls
v1.3.14 (released 2026-05-12) appears to ship fixes for both cpSync issues on Linux/FreeBSD — the symlink target resolution and the ENOENT when copying a symlink to a destination whose parent directory doesn't exist (https://bun.com/blog/bun-v1.3.14). Can this be closed?
Activity
robobun commentedon Apr 8, 2026
🔄 Rebased onto main. Main refactored the Linux symlink path into a
_cpSymlinkhelper (that resolves relative link targets againstdirname(src), matching Node) and added a FreeBSD path using the same helper. The rebase conflict was innode_fs.zig; resolved by wrapping the_cpSymlinkcalls on Linux and FreeBSD with the sameENOENT → makePath → retryfallback I already had for the macOScopyfileand WindowsCreateSymbolicLinkWbranches.Gate:
0 pass / 2 fail,ENOENT: no such file or directory, symlinkat thecpSynccalls2 pass / 0 failForce-pushed
4068bc0013.fs: create parent dirs when cpSync copies a symlink
fs: create parent dirs when cpSync copies a symlink
davidpoblador commentedon May 13, 2026
v1.3.14 (released 2026-05-12) appears to ship fixes for both cpSync issues on Linux/FreeBSD — the symlink target resolution and the ENOENT when copying a symlink to a destination whose parent directory doesn't exist (https://bun.com/blog/bun-v1.3.14). Can this be closed?