rcmdnk / homebrew-file

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

"IndexError: list index out of range" when running brew file casklist #300

Open obrientg opened 23 hours ago

obrientg commented 23 hours ago

Hello! I am working on getting brew-file running on various macbook pro's I own to make administration easier - and when configuring a new system. The current system I am working on is a MacBookPro11,5 running Monterey (12.7.6), with brew & all packages up to date (ran brew update/upgrade before starting this process).

I have gone through all the documentation posted on https://homebrew-file.readthedocs.io/en/latest/usage.html and the FAQ), but I am getting similar IndexError's when running casklist, or when looking to create the brew-file (which casklist seems to be the first step):

`brew file casklist

############################################

Starting to check applications for Cask...

############################################

Traceback (most recent call last): File "/usr/local/bin/brew-file", line 3892, in sys.exit(main())


  File "/usr/local/bin/brew-file", line 3879, in main
    b.execute()
    ~~~~~~~~~^^
  File "/usr/local/bin/brew-file", line 3170, in execute
    self.check_cask()
    ~~~~~~~~~~~~~~~^^
  File "/usr/local/bin/brew-file", line 2870, in check_cask
    appstore_list = self.get_appstore_dict()
  File "/usr/local/bin/brew-file", line 2008, in get_appstore_dict
    x.split("=")[0].strip(): x.split("=")[1].strip() for x in lines
                             ~~~~~~~~~~~~^^^
IndexError: list index out of range`

brew-file install ~/.config/Brewfile.craft --set_local
Traceback (most recent call last):
  File "/usr/local/bin/brew-file", line 3892, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/local/bin/brew-file", line 3879, in main
    b.execute()
    ~~~~~~~~~^^
  File "/usr/local/bin/brew-file", line 3180, in execute
    self.set_brewfile_local()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/bin/brew-file", line 2243, in set_brewfile_local
    _ = self.initialize(check=False, check_input=False)
  File "/usr/local/bin/brew-file", line 2324, in initialize
    self.get_installed_packages()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/bin/brew-file", line 2130, in get_installed_packages
    "appstore_list", self.get_appstore_list()
                     ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/bin/brew-file", line 2019, in get_appstore_list
    f"{v[0]} {k} {v[1]}" for k, v in self.get_appstore_dict().items()
                                     ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/bin/brew-file", line 2008, in get_appstore_dict
    x.split("=")[0].strip(): x.split("=")[1].strip() for x in lines
                             ~~~~~~~~~~~~^^^
IndexError: list index out of range

Your assistance and insights would be appreciated - thank you

(edited for formatting)

rcmdnk commented 14 hours ago

There seems something wrong happened when it tries to get apps information.

Could you please try following commands and give me outputs?

mdfind 'kMDItemAppStoreHasReceipt=1'
for app in $(mdfind 'kMDItemAppStoreHasReceipt=1');do echo $app;mdls -attr kMDItemAppStoreAdamID -attr kMDItemVersion $app;done
obrientg commented 13 hours ago

Sure

mdfind 'kMDItemAppStoreHasReceipt=1'

/Applications/Mattermost.app /Applications/Keynote.app /Applications/Numbers.app /Applications/iMovie.app /Applications/GarageBand.app /Applications/Pages.app /Applications/WireGuard.app

but if I run mdfind 'kMDItemAppStoreHasReceipt=1' for app in $(mdfind 'kMDItemAppStoreHasReceipt=1');do echo $app;mdls -attr kMDItemAppStoreAdamID -attr kMDItemVersion $app;done

-bash: syntax error near unexpected token `do'

or run

mdfind 'kMDItemAppStoreHasReceipt=1' for app in $(mdfind 'kMDItemAppStoreHasReceipt=1');

Unknown option -

Usage: mdfind [-live] [-count] [-onlyin directory] [-name fileName | -s smartFolderName | query] list the files matching the query query can be an expression or a sequence of words

-attr Fetches the value of the specified attribute -count Query only reports matching items count -onlyin

Search only within given directory -live Query should stay active -name Search on file name only -reprint Reprint results on live update -s Show contents of smart folder -0 Use NUL (``\0'') as a path separator, for use with xargs -0.

example: mdfind image example: mdfind -onlyin ~ image example: mdfind -name stdlib.h example: mdfind "kMDItemAuthor == 'MyFavoriteAuthor'" example: mdfind -live MyFavoriteAuthor

rcmdnk commented 12 hours ago

Could you please try (starting from for)?:

for app in $(mdfind 'kMDItemAppStoreHasReceipt=1');do echo $app;mdls -attr kMDItemAppStoreAdamID -attr kMDItemVersion $app;done