I'm curious why it only seems to happen sometimes.
The short answer is… well… there isn’t a short answer )-:
Apple uses cryptex to securely ship small software updates. To learn more, read the cryptex
man page.
The contents of the cryptex get grafted into the file system at the expected place, but the cryptex is also visible at its mount point. Consider this:
% ls -i /System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app/Contents/Info.plist
72138 /System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app/Contents/Info.plist
% ls -i /Applications/Safari.app/Contents/Info.plist
72138 /Applications/Safari.app/Contents/Info.plist
Both of these files have the same inode number, meaning that they’re actually the same file.
Tools like Spotlight and Launch Services scans files in the order in which they discover them, so it’s possible for them to find the cryptex copy of Safari before the ‘real’ one, and vice versa.
Additionally, when you use the code signing APIs to find a path for a file, it ends up walking up the directory hierarchy to build that path. If there are multiple paths to the file, the exact one you get depends on the state of the name cache within the kernel.
Note Cryptexes aren’t the only way this crops up; you’ll see the same thing with hard links.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"