Skip to content

internal/utils/reflink: build fails on darwin (no reflink_darwin.go) #61

@mrjf

Description

@mrjf

Summary

go build ./... and go test ./internal/utils/reflink fail on macOS because the package has no darwin-specific implementation file and the existing build tags exclude darwin from both alternatives.

Reproduction

Tested at commit 14b9a73 on darwin/arm64, go1.26.2:

$ go build ./...
# github.com/githubnext/apm/internal/utils/reflink
internal/utils/reflink/reflink.go:38:13: undefined: platformClone
internal/utils/reflink/reflink.go:55:14: undefined: deviceID
internal/utils/reflink/reflink.go:65:9: undefined: platformSupported

$ GOOS=linux go build ./...    # passes

Root cause

The package contains:

  • reflink_linux.go//go:build linux
  • reflink_other.go//go:build !linux && !darwin
  • reflink.go — platform-agnostic dispatcher that calls platformClone, deviceID, platformSupported

On darwin, neither tagged file is selected, so the three helper symbols are undefined.

Notably, the dispatcher's own doc comment promises darwin support:

Modern filesystems (APFS on macOS, btrfs and XFS on Linux) support copy-on-write clones.

So a darwin implementation was intended but never landed.

Suggested fixes

Either:

  1. Implement it properly — add reflink_darwin.go using clonefile(2) (APFS supports this natively via clonefileat/clonefile in <sys/clonefile.h>), matching the linux signatures. This honors the stated intent of the package.
  2. Stub it temporarily — broaden reflink_other.go's build tag from !linux && !darwin to !linux, accepting the fallback (non-reflink) path on darwin until a real APFS implementation lands.

Option 2 unblocks the build immediately; option 1 delivers the documented behavior.

Related

Filing a separate issue for the underlying reason this wasn't caught: CI only runs on Ubuntu, so darwin-only build breaks are invisible.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions