Skip to content

fs.cpSync with dereference: true does not dereference (regression in 22.17) #59168

@robhogan

Description

@robhogan

Version

22.17.1 and 22.17.0

Platform

Darwin 24.5.0

Subsystem

fs

What steps will reproduce the bug?

workspace  nvm use 22.16
Using Node v22.16.0
 workspace  rm -rf node-repro; mkdir node-repro && cd node-repro && mkdir src linked && touch linked/foo && ln -s ../linked/foo src/bar && node -e "fs.cpSync('./src', './out', {dereference: true, recursive: true})" && ls -la out && cd ..
total 0
drwxr-xr-x  3 robhogan  staff   96 22 Jul 15:14 .
drwxr-xr-x  5 robhogan  staff  160 22 Jul 15:14 ..
-rw-r--r--  1 robhogan  staff    0 22 Jul 15:14 bar
 workspace  nvm use 22.17.0
Using Node v22.17.0
 workspace  rm -rf node-repro; mkdir node-repro && cd node-repro && mkdir src linked && touch linked/foo && ln -s ../linked/foo src/bar && node -e "fs.cpSync('./src', './out', {dereference: true, recursive: true})" && ls -la out && cd ..
total 0
drwxr-xr-x  3 robhogan  staff   96 22 Jul 15:14 .
drwxr-xr-x  5 robhogan  staff  160 22 Jul 15:14 ..
lrwxr-xr-x  1 robhogan  staff   47 22 Jul 15:14 bar -> /Users/robhogan/workspace/node-repro/linked/foo

How often does it reproduce? Is there a required condition?

Appears to reproduce consistently, no known conditions

What is the expected behavior? Why is that the expected behavior?

In all versions up to 22.17, when {dereference: true} was passed as an option to fs.cpSync, any symlinks in the source directory would be dereferenced and their targets copied to the destination.

What do you see instead?

In 22.17, a symlink is created in destination instead of a copy of the symlink's target, which is the same as {dereference: false}.

Additional information

Appears closely related to #58939 and probably has the same blame commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.regressionIssues related to regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions