1

Some macOS installations include the Unix realpath command and some do not. I haven't been able to discern an accurate pattern of which versions have it.

I'm on an M1 Air with Monterrey 12.6 and Xcode 13.4.1 and I do not have it. (I am also not using Homebrew.) I also don't have access to any other Macs.

I'm trying to find out whether this realpath resolves Apple's new "firmlinks" which are a feature of the APFS filesystem.

An example of a firmlink is /System/Volumes/Data/Applications which links to /Applications

To test your system you can enter these commands in your Terminal:

  • which realpath
  • realpath /System/Volumes/Data/Applications

(Note that the ls command does not report firmlinks no matter what switches you use.)

1

1 Answer 1

2

No, it doesn't.

imac:barmar $ realpath /Applications
/Applications
imac:barmar $ realpath /System/Volumes/Data/Applications
/System/Volumes/Data/Applications
10
  • 1
    And I think it would be very surprising if it did. The POSIX/Unix executables distributed with macOS are agnostic about the underlying file system. Firmlinks (and directory hard links), unlike symbolic and file hard links, are apply only to specific Apple file systems.
    – Gilby
    Nov 5, 2022 at 22:46
  • 1
    I don't think that's entirely true. ls will show a special flag if the file has MacOS attributes, cp has an option to preserve extended attributes and resource forks.
    – Barmar
    Nov 6, 2022 at 0:43
  • For anyone interested, I got here because I'm learning Swift, Zig, and Rust and wrote some code using the default directory walker of each language's std lib. They behave differently. Swift's doesn't follow firmlinks while Rust's and Zig's do. Rust's uses the system realpath while Zig implements its own realpath which does resolve firmlinks. I'm investigating which ones are doing it right or wrong or lack way to detect firmlinks to avoid duplicate dir traversals like Swift does. Nov 6, 2022 at 6:18
  • 1
    @hippietrail I was basing my thoughts on the layering of functionality in all OS - not on any detailed knowledge! The BSD/Posix/Unix layer sits above any specifics of file systems. So is unlikely to know about firmlinks (APFS) or Directory Hardlinks (HFS+).
    – Gilby
    Nov 6, 2022 at 8:03
  • 1
    @Barmar This is all a bit rubbery/waffly on my part, but I don't think ls may not be a counter example of my argument. xattrs are present on other Unix and linux OSs so I would expect macOS ls to know about them. But this is a side discussion - you have provided the correct answer and now has a tick and 2 votes -presumably hippietrail and me!
    – Gilby
    Nov 6, 2022 at 8:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .