While developing a macOS application that lists folder contents I found that macOS Monterey does not list folders properly. Some files and folders are simply skipped.
/Applications/Utilities contains 22 items when I look in the Finder:
Activity Monitor.app Adobe Application Manager Adobe Creative Cloud Adobe Creative Cloud Experience Adobe Genuine Service Adobe Sync AirPort Utility.app Audio MIDI Setup.app Bluetooth File Exchange.app ColorSync Utility.app Console.app Digital Colour Meter.app Disk Utility.app Feedback Assistant.app Grapher.app Keychain Access.app Migration Assistant.app Screenshot.app Script Editor.app System Information.app Terminal.app VoiceOver Utility.app
But when using
/bin/ls /Applications/Utilities only 7 are shown:
-rw-r--r-- 1 root wheel 0 May 9 23:30 .localized drwxr-xr-x@ 4 root wheel 128 Oct 9 2019 Adobe Application Manager drwxr-xr-x@ 8 root wheel 256 Oct 21 2020 Adobe Creative Cloud drwxrwxr-x@ 3 root wheel 96 Oct 21 2020 Adobe Creative Cloud Experience drwxr-xr-x 4 root wheel 128 May 20 13:01 Adobe Genuine Service drwxrwxr-x@ 5 root wheel 160 Oct 21 2020 Adobe Sync lrwxr-xr-x 1 root wheel 64 Oct 21 2018 Feedback Assistant.app -> /System/Library/CoreServices/Applications/Feedback Assistant.app
At first I thought I missed the fact that
.app files are really folders and therefore not shown, but
/bin/ls /Applications DOES show all apps.
I also considered permissions may be different but even when running using
sudo nothing changes. Even granting the Terminal full disk access in the System preferences changes nothing.
What is going on?