rcmdnk / homebrew-file

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

IndexError: list index out of range #267

Closed konnano closed 6 months ago

konnano commented 7 months ago

こんにちは、brew-file, brew bundle どちらを使うか試してみました

brew-file を使うとエラーになります

(Desktop):brew file init
Do you want to set a repository (y)? ((n) for local Brewfile). [y/n]: n Traceback (most recent call last): File "/usr/local/bin/brew-file", line 3639, in sys.exit(main()) ^^^^^^ File "/usr/local/bin/brew-file", line 3626, in main b.execute() File "/usr/local/bin/brew-file", line 2947, in execute _ = self.initialize() ^^^^^^^^^^^^^^^^^ File "/usr/local/bin/brew-file", line 2164, in initialize self.get_installed_packages() File "/usr/local/bin/brew-file", line 2010, in get_installed_packages "appstore_list", self.get_appstore_list() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/bin/brew-file", line 1927, 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 1916, in get_appstore_dict x.split("=")[0].strip(): x.split("=")[1].strip() for x in lines


IndexError: list index out of range

mas-cli/tap/mas, version 1.8.1 で転けてるのかと
mas-cli/tap/masをuninstallしても同じエラーです

brew bundle を使うと別のエラーが出ました

(Desktop):brew bundle dump
Error: Formulae dependency graph sorting failed (likely due to a circular dependency):
aom: ["brotli", "giflib", "highway", "imath", "jpeg-turbo", "libpng", "xz", "lz4", "zstd", "libtiff", "little-cms2", "openexr", "webp", "jpeg-xl", "libvmaf"]
libavif: ["brotli", "giflib", "highway", "imath", "jpeg-turbo", "libpng", "xz", "lz4", "zstd", "libtiff", "little-cms2", "openexr", "webp", "jpeg-xl", "libvmaf", "aom"]
Please run the following commands and try again:
  brew update
  brew uninstall --ignore-dependencies --force aom libavif
  brew install aom libavif

ただこれも間違ってます、実際には jpeg-xl と libavif が循環参照しています

formula.jws.json には記載されて居ません ダイレクトに以下に記載されてます

<details><summary>/usr/local/Cellar/jpeg-xl/0.10.2/INSTALL_RECEIPT.json</summary>

```
(Desktop):cat /usr/local/Cellar/jpeg-xl/0.10.2/INSTALL_RECEIPT.json 
{
  "homebrew_version": "4.2.18-74-g401500e-dirty",
  "used_options": [

  ],
  "unused_options": [

  ],
  "built_as_bottle": false,
  "poured_from_bottle": false,
  "loaded_from_api": false,
  "installed_as_dependency": false,
  "installed_on_request": true,
  "changed_files": null,
  "time": 1713581825,
  "source_modified_time": 1709885458,
  "compiler": "llvm_clang",
  "aliases": [

  ],
  "runtime_dependencies": [
    {
      "full_name": "brotli",
      "version": "1.1.0",
      "revision": 0,
      "pkg_version": "1.1.0",
      "declared_directly": true
    },
    {
      "full_name": "giflib",
      "version": "5.2.1",
      "revision": 0,
      "pkg_version": "5.2.1",
      "declared_directly": true
    },
    {
      "full_name": "highway",
      "version": "1.1.0",
      "revision": 0,
      "pkg_version": "1.1.0",
      "declared_directly": true
    },
    {
      "full_name": "imath",
      "version": "3.1.11",
      "revision": 0,
      "pkg_version": "3.1.11",
      "declared_directly": true
    },
    {
      "full_name": "jpeg-turbo",
      "version": "3.0.2",
      "revision": 0,
      "pkg_version": "3.0.2",
      "declared_directly": true
    },
    {
      "full_name": "libpng",
      "version": "1.6.43",
      "revision": 0,
      "pkg_version": "1.6.43",
      "declared_directly": true
    },
    {
      "full_name": "xz",
      "version": "5.4.6",
      "revision": 0,
      "pkg_version": "5.4.6",
      "declared_directly": false
    },
    {
      "full_name": "lz4",
      "version": "1.9.4",
      "revision": 0,
      "pkg_version": "1.9.4",
      "declared_directly": false
    },
    {
      "full_name": "zstd",
      "version": "1.5.6",
      "revision": 0,
      "pkg_version": "1.5.6",
      "declared_directly": false
    },
    {
      "full_name": "libtiff",
      "version": "4.6.0",
      "revision": 0,
      "pkg_version": "4.6.0",
      "declared_directly": false
    },
    {
      "full_name": "little-cms2",
      "version": "2.16",
      "revision": 0,
      "pkg_version": "2.16",
      "declared_directly": true
    },
    {
      "full_name": "openexr",
      "version": "3.2.4",
      "revision": 0,
      "pkg_version": "3.2.4",
      "declared_directly": true
    },
    {
      "full_name": "webp",
      "version": "1.4.0",
      "revision": 0,
      "pkg_version": "1.4.0",
      "declared_directly": true
    },
    {
      "full_name": "libavif",
      "version": "1.0.4",
      "revision": 0,
      "pkg_version": "1.0.4",
      "declared_directly": false
    }
  ],
  "source": {
    "path": "/Users/konnano/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/69436805177133e8607da35994e9bd57161c5fb6/Formula/jpeg-xl.rb",
    "tap": "homebrew/core",
    "tap_git_head": "3b134f092b3a266fee4b471f996f35f4e15eaef0",
    "spec": "stable",
    "versions": {
      "stable": "0.10.2",
      "head": null,
      "version_scheme": 0
    }
  },
  "arch": "x86_64",
  "built_on": {
    "os": "Macintosh",
    "os_version": "macOS 10.13.6",
    "cpu_family": "ivybridge",
    "xcode": "10.1",
    "clt": "10.1.0.0.1.1539992718",
    "preferred_perl": "5.18"
  }
}%                                                                                                                 
```

</details>

brew uninstall --ignore-dependencies --force jpeg-xl libavif
brew install jpeg-xl libavif
しても治りません、HomebrewのバグなのかOSが古すぎるのか理由が分かんない

/usr/local/Cellar/jpeg-xl/0.10.2/INSTALL_RECEIPT.json の

  ,
   {
      "full_name": "libavif",
      "version": "1.0.4",
      "revision": 0,
      "pkg_version": "1.0.4",
      "declared_directly": false
    }

を削除すると brew bundle は成功します、brew-file は同じエラーになります

(Desktop):brew config
HOMEBREW_VERSION: 4.2.19-87-ga47c45d-dirty
ORIGIN: https\://github.com/Homebrew/brew
HEAD: a47c45dbda86617c3eb0571f2830771aec7cb929
Last commit: 4 hours ago
Core tap HEAD: 069d96afa3202d2b654add23e5539de66d23151c
Core tap last commit: 4 hours ago
Core tap JSON: 25 Apr 08:41 UTC
Core cask tap HEAD: cb02f7880faecf08d6a9a986a987d42737311f34
Core cask tap last commit: 3 hours ago
Core cask tap JSON: 25 Apr 08:41 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: :0
HOMEBREW_EDITOR: vim
HOMEBREW_MAKE_JOBS: 4
HOMEBREW_NO_INSTALL_FROM_API: set
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.1.4 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: quad-core 64-bit ivybridge
Clang: 10.0.0 build 1000
Git: 2.44.0 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
macOS: 10.13.6-x86_64
CLT: 10.1.0.0.1.1539992718
Xcode: 10.1
rcmdnk commented 7 months ago

手元のmacで見てみたところ(rosetta環境のx86_64な環境で) jpeg-xlはlibavifに依存関係を持っていませんでした。

/usr/local/Cellar/jpeg-xl/0.10.2/INSTALL_RECEIPT.json ``` { "homebrew_version": "4.2.18-38-g726d65c", "used_options": [ ], "unused_options": [ ], "built_as_bottle": true, "poured_from_bottle": true, "loaded_from_api": true, "installed_as_dependency": false, "installed_on_request": true, "changed_files": [ "lib/pkgconfig/libjxl.pc", "lib/pkgconfig/libjxl_cms.pc", "lib/pkgconfig/libjxl_threads.pc" ], "time": 1714101236, "source_modified_time": 1709885458, "compiler": "clang", "aliases": [ ], "runtime_dependencies": [ { "full_name": "brotli", "version": "1.1.0", "revision": 0, "pkg_version": "1.1.0", "declared_directly": true }, { "full_name": "giflib", "version": "5.2.2", "revision": 0, "pkg_version": "5.2.2", "declared_directly": true }, { "full_name": "highway", "version": "1.1.0", "revision": 0, "pkg_version": "1.1.0", "declared_directly": true }, { "full_name": "imath", "version": "3.1.11", "revision": 0, "pkg_version": "3.1.11", "declared_directly": true }, { "full_name": "jpeg-turbo", "version": "3.0.2", "revision": 0, "pkg_version": "3.0.2", "declared_directly": true }, { "full_name": "libpng", "version": "1.6.43", "revision": 0, "pkg_version": "1.6.43", "declared_directly": true }, { "full_name": "xz", "version": "5.4.6", "revision": 0, "pkg_version": "5.4.6", "declared_directly": false }, { "full_name": "lz4", "version": "1.9.4", "revision": 0, "pkg_version": "1.9.4", "declared_directly": false }, { "full_name": "zstd", "version": "1.5.6", "revision": 0, "pkg_version": "1.5.6", "declared_directly": false }, { "full_name": "libtiff", "version": "4.6.0", "revision": 0, "pkg_version": "4.6.0", "declared_directly": false }, { "full_name": "little-cms2", "version": "2.16", "revision": 0, "pkg_version": "2.16", "declared_directly": true }, { "full_name": "openexr", "version": "3.2.4", "revision": 0, "pkg_version": "3.2.4", "declared_directly": true }, { "full_name": "webp", "version": "1.4.0", "revision": 0, "pkg_version": "1.4.0", "declared_directly": true } ], "source": { "spec": "stable", "versions": { "stable": "0.10.2", "head": null, "version_scheme": 0 }, "path": "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/j/jpeg-xl.rb", "tap_git_head": "76f08feae42d2f363b850d6cb2dbaaed554ff9e9", "tap": "homebrew/core" }, "arch": "x86_64", "built_on": { "os": "Macintosh", "os_version": "macOS 14.4", "cpu_family": "penryn", "xcode": "15.3", "clt": "15.3.0.0.1.1708646388", "preferred_perl": "5.34" } } ```

最新の Formulaを見ても依存してないようです。 https://github.com/Homebrew/homebrew-core/blob/master/Formula/j/jpeg-xl.rb

少なくとも0.10.2では依存していた形跡もないですね。

ちょっと分かりかねますが、Homebrew自体はmacOS 12以上をsupportしているので10.13で何かしら不具合があっても分かりません。 https://docs.brew.sh/Installation

関係ないかもしれませんが、現在安定バージョンではないHomebrewを使っているみたいなので、stableに戻して見てみるとなにか変わるかもしれません。

cd /usr/local/Homebrew
git status # おそらくmasterなどになっている
brew developer state # おそらくenabledになっている
brew developer off
git checkout stable # その前にgit checkout . をして変更を戻す必要があるかも
command brew update
command brew doctor 

これで問題なさそうならbrew file initを試してみる。

konnano commented 6 months ago

解答ありがとうございます 安定板にしましたがダメでした brew doctor 当たり前に警告でます brew-file は後方互換あまり意識してない様ですね 循環参照の対策してるのかと期待したのですが残念です vim の全角 esc 半角切り替えソース使ってますよ 😁

rcmdnk commented 6 months ago

上のエラーですが、brew-fileのエラーとしては循環参照とは別の問題のようです。 AppStoreのアプリ一覧を取るところでコケてます。

以下のコマンドを試してみてもらえますか?

mdfind 'kMDItemAppStoreHasReceipt=1'

これに対して、

/Applications/Numbers.app
/Applications/Keynote.app
/Applications/Pages.app
/Applications/iMovie.app
/Applications/Xcode.app

の様なアプリ一覧(AppStoreから入れたもの)が出てくるのが通常です。

さらに

$ mdls -attr kMDItemAppStoreAdamID -attr kMDItemVersion '/Applications/Numbers.app'
kMDItemAppStoreAdamID = 409203825
kMDItemVersion        = "14.0"

のように各アプリの情報が取れるはずなのでもし上がうまく行ったらためしてみてください。

これらのコマンドがどのmacOSのバージョンから同じように使えるか把握していませんが、 おそらくmdfind 'kMDItemAppStoreHasReceipt=1'の時点でエラーがでてその後のコマンドもエラー出力になってしまっていてただしくparse出来ないのだと思っています。

古いバージョンで確認が難しいですが、AppStoreのアプリのリストをなしにした状態で使うことは可能かと思います。

以下のコマンドを試してみてください。

HOMEBREW_BREWFILE_APPSTORE=0 brew file init

これでappstoreなパッケージ以外のリストが出来ます。

もしこれでも良ければ .bashrcなどに

export HOMEBREW_BREWFILE_APPSTORE=0

を書いて設定しておけばbrew file initコマンドなどbrew fileコマンドだけで使えるようになるはずです。

konnano commented 6 months ago

ありがとうございます、これで取れました

HOMEBREW_BREWFILE_APPSTORE=0 brew file init

(Homebrew):mas list

1440147259  AdGuard for Safari          (1.11.17)
630315610   Clock                       (1.1.0)
441258766   Magnet                      (2.14.0)
405399194   Kindle                      (1.33.0)
409183694   Keynote                     (9.1)
408981381   iPhoto                      (9.6.1)
408981434   iMovie 10                   (10.1.12)
682658836   GarageBand 10               (10.3.5)
408980954   GarageBand 6                (6.0.5)
963642514   Duplicate Photos Fixer Pro  (4.10)
409201541   Pages                       (8.1)
539883307   LINE                        (6.7.1)
408981434   iMovie 9                    (9.0.9)
409203825   Numbers                     (6.1)

(Homebrew):mdfind 'kMDItemAppStoreHasReceipt=1'

/Applications/Pages.app
/Applications/LINE.app
/Applications/GarageBand 10.app
/Applications/Keynote.app
/Applications/AdGuard for Safari.app
/Applications/Magnet.app
/Applications/Clock.app
/Applications/iMovie 9.app
/Applications/iPhoto.app
/Applications/Duplicate Photos Fixer Pro.app
/Applications/iMovie 10.app
/Applications/GarageBand 6.app
/Applications/Kindle.app
/Applications/Numbers.app

(Homebrew):mdls -attr kMDItemAppStoreAdamID -attr kMDItemVersion '/Applications/Numbers.app'

mdls: unrecognized option `-attr'

usage: mdls [-name attr] [-raw [-nullMarker markerString]] [-plist file] path
list the values of one or all the attributes of the specified file
  -raw:         don't print attribute names before values
  -nullMarker:  substitute this string for null attributes in raw mode
  -plist:       output attributes in XML format to file. Use - to write to stdout
                option -plist is incompatible with options -raw, -nullMarker, and -name
example:  mdls  ~/Pictures/Birthday.jpg
example:  mdls  -name Keyword ~/Pictures/Birthday.jpg

Homebrew):mdls attr kMDItemAppStoreAdamID attr kMDItemVersion '/Applications/Numbers.app'

attr: could not find attr.