rcmdnk / homebrew-file

Brewfile manager for Homebrew
http://homebrew-file.readthedocs.io/
MIT License
356 stars 29 forks source link

some `brew-file` operations fail when `mdfind` returns bad information #284

Open zcutlip opened 2 months ago

zcutlip commented 2 months ago

This is a hard problem to reproduce. Occasionally spotlight seems to have improperly indexed /Applications, and this causes brew-file to break.

The last time it happened, I ran brew file update, and got the following error:

[ERROR] Failed at command: mdls -attr kMDItemAppStoreAdamID -attr kMDItemVersion bad path C66D0C00-0000-0000-9000-006B00000000
bad path C66D0C00-0000-0000-9000-006B00000000: could not find bad path C66D0C00-0000-0000-9000-006B00000000.

I tracked it down to a problem with the output of mdfind 'kMDItemAppStoreHasReceipt=1':

/Applications/Wallaroo.app
/Applications/Kagi for Safari.app
/Applications/PCalc.app
/Applications/AutoMounter.app
/Applications/NewFileMenu.app
/Applications/Okta Verify.app
/Applications/Screens 5.app
/Applications/Discovery.app
/Applications/StopTheMadness Pro.app
bad path C66D0C00-0000-0000-9000-006B00000000
bad path 19F07200-0000-0000-9000-006B00000000
bad path A6420E00-0000-0000-9000-006B00000000
bad path B6286400-0000-0000-9000-006B00000000
bad path 93467800-0000-0000-9000-006B00000000

I fix it by disabling/reenabling spotlight, forcing a re-index, but it eventually comes back.

Of course the real problem is with spotlight and not brew-file, but I'm filing the issue in case brew-file wants to be more robust when processing mdfind output.

rcmdnk commented 2 months ago

Though I could not reproduce the problem, I added to check the app there. If it is wrong name (or if the app does not exist), brew-file just shows warning and continues. Could you please try v9.0.19?