Commands like list, outdated, get, install, lucky, update, and uninstall rely on the Spotlight Metadata Service (MDS) to find installed apps. If an app is not appearing in mas results, it may not be indexed in Spotlight.
1. Verify if an app is indexed:
Use mdls to check for the kMDItemAppStoreAdamID attribute:
mdls -rn kMDItemAppStoreAdamID /Applications/Xcode.app
If it outputs nothing, the app is not indexed.
2. Find an app path via ADAM ID:
mdfind 'kMDItemAppStoreAdamID = <adam-id>'
3. Fix indexing:
- Individual app:
mdimport /Applications/Xcode.app - All apps on primary volume:
vol="$(/usr/libexec/PlistBuddy -c "Print :PreferredVolume:name" ~/Library/Preferences/com.apple.appstored.plist 2>/dev/null)"
mdimport /Applications "${vol:+"/Volumes/${vol}/Applications"}"
- All volumes:
sudo mdutil -Eai on
# Check if Xcode is indexed
mdls -rn kMDItemAppStoreAdamID /Applications/Xcode.app