7

I haven't upgraded from macOS 12.6 to Ventura yet.

I have no realpath command in my /bin directory, or anywhere else on my M1 MacBook Air.

I've never installed brew/homebrew on my Mac though I've been told by other developers that brew can't install anything in /bin anyway.

But another developer who has upgraded to Ventura tells me there is a realpath in their /bin and it's signed with the Identifier com.apple.realpath

Can anybody confirm that realpath did not come with macOS Monterrey but has been added to macOS Ventura?

hippietrail
  • 1,344
  • 1
    /bin/realpath is there in my Ventura on an M1 mini – mmmmmm Nov 04 '22 at 09:35
  • 1
    And on my Ventura Intel Macs. Since realpath is part of POSIX and macOS is POSIX compliant, I assume it has always been there (but maybe not). – Gilby Nov 04 '22 at 09:42
  • 4
    Interesting... I'm still on Monterey (Intel Mac) and can confirm that there is no command realpath. – jaume Nov 04 '22 at 10:09
  • 1
    And Homebrew installs it as /usr/local/bin/realpath – glenn jackman Nov 04 '22 at 13:35
  • 2
    @jaume It's absent here on ARM Monterey, too. @glennjackman That's the path on Intel; on ARM Homebrew uses (by default) /opt/homebrew/bin/. – gidds Nov 04 '22 at 22:58
  • 1
    I have an ARM machine on Monterey and realpath is present – Ezekiel Nov 05 '22 at 02:01
  • @Ezekiel Is it present in /bin or in /opt/homebrew/bin? Or somewhere else? – hippietrail Nov 05 '22 at 08:13
  • 1
    https://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac would seem to be an extensive answer to this question but not to OP's actual question. – Marc Wilson Nov 05 '22 at 14:30
  • 1
    I also have it in M1 Ventura in /bin but not /opt/homebrew/bin. – Barmar Nov 05 '22 at 19:34
  • 1
    @hippietrail Mine is in /bin – Ezekiel Nov 06 '22 at 03:54
  • 1
    Is XCode installing the realpath binary? I'm not going to install XCode to find out, but it seems reasonable that it might? All three of my Monterey machines (1x M1, 2x Intel, all 12.6.1) do not have it. – Marc Wilson Nov 07 '22 at 14:59
  • @MarcWilson: I wondered that too. I've had Xcode installed since I got this laptop but I haven't upgraded past 13.4.1 yet since I'll have to dig out some external drives to make enough space temporarily. – hippietrail Nov 08 '22 at 12:58
  • 1
    No, XCode is not installing realpath, you can take a look running ls -1 /Library/Developer/CommandLineTools/usr/bin. realpath was indeed introduced in macOS Ventura 13.0 – Aeronautix Oct 30 '23 at 08:51

1 Answers1

6

To the headline question: Yes.

On an Intel Mac (I can't see why an M1 Mac would be different):

  1. My macOS 13 has /bin/realpath.
  2. The executable has the same date and time as all other files in /usr/bin. Here is an ls snippet.
-rwsr-xr-x   1 root  wheel   203584 18 Oct 23:36 ps
-rwxr-xr-x   1 root  wheel   134064 18 Oct 23:36 pwd
-rwxr-xr-x   1 root  wheel   133840 18 Oct 23:36 realpath
-rwxr-xr-x   2 root  wheel   135424 18 Oct 23:36 rm
-rwxr-xr-x   1 root  wheel   133808 18 Oct 23:36 rmdir
  1. /bin is only on the sealed system volume, so nothing apart from a macOS install or update could have put realpath in /bin.
  2. I am a homebrew user, but there is no homebrew version of realpath:
% brew info realpath
Error: No available formula with the name "realpath".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.

Note that it is true (see @nohillside's comment) that realpath can be installed by brew as part of coreutils. I suggest caution with coreutils because of the potential for name clashes.

  1. @Barmar has commented above that realpath is in /bin on M1 Ventura.

  2. I have a copy of all macOS 12 man pages. There is no man page for realpath. (This is a slightly indirect way of saying not present in Monterey).

  3. There are new questions popping up on the web about realpath and Ventura. This also indicates that it was not installed previously.

I conclude that:

  1. realpath is part of macOS 13 on both Intel and AS.
  2. realpath was not in macOS 12.
  3. realpath is not in homebrew as a distinct item.
Gilby
  • 10,852
  • 1
    In Homebrew, realpath is part of coreutils (and it doesn't know about firmlinks). Does man realpath on macOS 13 imply that it does? – nohillside Nov 05 '22 at 21:37
  • 2
    man realpath says "The realpath utility uses the realpath(3) function to resolve all symbolic links...". No mention of firmlinks - so I assume not. – Gilby Nov 05 '22 at 21:46
  • brew info coreutils has warnings about conflicting binaries and adding a leading g to some names (likely not yet to its realpath). Use coreutils with care. – Gilby Nov 05 '22 at 21:56
  • 1
    The reason I'm delving into all this is because the Swift directory-walking functionality does not follow symlinks or firmlinks but I don't think we have its source to see its implementation. Rust's directory-walker does follow firmlinks, leading to duplicate traversals. Its realpath doesn't resolve firmlinks. Zig's dir-walker also follows firmlinks but its realpath does resolve firmlinks. I'm down the rabbithole trying to figure out which language's standard library might be missing what funcitonality. – hippietrail Nov 06 '22 at 06:14
  • 1
    @hippietrail It‘s in the nature of firmlinks that standard unix library functions are not aware of their existence. But in general, questions about how library handle firmlinks are better suited for StackOverflow. – nohillside Nov 06 '22 at 07:50
  • 1
    @nohillside: Yes I'm asking programming questions about the realpath() standard library function on StackOverflow but questions about the macOS version of the realpath shell command here. Sometimes I post a bit of explanation in case people think I'm asking an X/Y question. – hippietrail Nov 06 '22 at 08:00
  • Note the realpath binary is not part od POSIX - the command line glags differ between GNU and macOS e.g. -f . man only gives the C function call. – mmmmmm Mar 17 '23 at 16:27
  • realpath introduced in macOS Ventura 13.0 (October 2022), readlink -f introduced in macOS Monterey 12.3 (March 2022), see also Which macOS version introduced "readlink -f"? – Aeronautix Oct 30 '23 at 08:45