Skip to content

macOS binaries: UV_FS_COPYFILE_FICLONE not supported #24521

Closed
@cristianl

Description

@cristianl

Node binaries from the official pkg distribution do not support copy-on-write (UV_FS_COPYFILE_FICLONE) on apfs-formatted volumes.

  • Version: v11.2.0
  • Platform: Darwin iMac.local 17.7.0 Darwin Kernel Version 17.7.0: Wed Oct 10 23:06:14 PDT 2018; root:xnu-4570.71.13~1/RELEASE_X86_64 x86_64
  • Subsystem: fs

Steps to reproduce

Generate a file (3MB here, size is not important) to clone later

mkdir ~/apfs-cow-test && cd ~/apfs-cow-test
head -c 3000000 </dev/urandom >origfile
node

In the node REPL, run:

const fs = require('fs')
fs.copyFile('origfile', 'newfile', fs.constants.UV_FS_COPYFILE_FICLONE_FORCE, err => { if (err) { console.log(err) }})

In the official node binary, this error is raised:

> { [Error: ENOSYS: function not implemented, copyfile 'origfile' -> 'newfile']
  errno: -78,
  code: 'ENOSYS',
  syscall: 'copyfile',
  path: 'origfile',
  dest: 'newfile' }

With a binary that supports this feature, the file is cloned normally. You can verify that the clone call works as intended by cloning a large file and checking the volume size on Disk Utility. It doesn't create a hardlink. Changes to the clone don't affect the original file.

Implications

This bug also affects users of nvm and n who install prebuilt binaries (the default behavior). brew users are not impacted as the prebuilt binary (bottle) is built with support for this flag.

Yarn is directly affected by this. UV_FS_COPYFILE_FICLONE falls back to normal copying, negating the performance and disk space benefits of cloning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.macosIssues and PRs related to the macOS platform / OSX.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions