This will stop working in the next version of macOS:
New in macOS Big Sur 11 beta, the system ships with a built-in dynamic linker cache of all system-provided libraries. As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail. Instead, check for library presence by attempting to
dlopen()the path, which will correctly check for the library in the cache. (62986286)
(@akoeplinger pointed this out offline)
I just tried on an macOS 11 installation and it looks like /usr/lib/libc.dylib is still there, even though with a broken symlink:
/usr/lib/libc.dylib -> /usr/lib/libSystem.dylib -> libSystem.B.dylib (doesn't exist)
The File.Exists() check still returns true so we should be good for now. There's still the possibility that Apple just didn't remove this .dylib in the first Beta though so we need to keep an eye on it.
We should probably just call RuntimeInformation.IsOSPlatform(OSPlatform.OSX) anyway; I don't think there's a need to roll it our own way any more.
Agreed.
@rainersigwald / @akoeplinger looks like libc is now gone for good in macOS 11.0 Beta 3 and it is causing issues like these https://gist.github.com/dalexsoto/9e8f2c804ec7ba2adac36360d1059ea4
alex@iDxBS ~ % ls -l /usr/lib/libc.dylib
ls: /usr/lib/libc.dylib: No such file or directory
Yeah, confirmed it is gone on my macOS 11 beta 3 too...
Most helpful comment
We should probably just call
RuntimeInformation.IsOSPlatform(OSPlatform.OSX)anyway; I don't think there's a need to roll it our own way any more.