Cask ‘inkscape’ definition is invalid: invalid depends_on key: ‘:x11’

brew upgradeしたら、inkscape の x11のほにゃららエラーでいきづまっちゃたよ

$ brew upgrade ==> Casks with 'auto_updates' or 'version :latest' will not be upgraded; pass `--greedy` to upgrade them. ==> Upgrading 5 outdated packages: Error: Cask 'inkscape' definition is invalid: invalid depends_on key: ':x11'
Code language: Bash (bash)

brew remove inkscapeもできない...

https://gist.github.com/muumin/0f335739cc0a06a0decc004141a6b4e8
に似たようなエラーを見つけた。

こんな感じのコマンドを実行すると解決するらしい

/usr/bin/find "$(brew --prefix)/Caskroom/"*'/.metadata' -type f -name '*.rb' -print0 | /usr/bin/xargs -0 /usr/bin/sed -i '' '/depends_on x11:/d'
Code language: Bash (bash)

findでファイルを検索して、sedで置換するみたいだね。いきなり実行するのはちょっとこわいので、少しづつ実行してみることに。

まず、$(brew --prefix)

$ brew --prefix /usr/local
Code language: Bash (bash)

次に findしてみると、

$ /usr/bin/find "$(brew --prefix)/Caskroom/"*'/.metadata' -type f -name '*.rb' -print0 /usr/local/Caskroom/android-studio/.metadata/3.4.1.0,183.5522156/20190603094537.564/Casks/android-studio.rb /usr/local/Caskroom/apache-couchdb/.metadata/3.1.0/20200515015701.723/Casks/apache-couchdb.rb /usr/local/Caskroom/db-browser-for-sqlite/.metadata/3.11.2/20191107133732.184/Casks/db-browser-for-sqlite.rb /usr/local/Caskroom/diffmerge/.metadata/4.2.1.1013/20190607031447.313/Casks/diffmerge.rb /usr/local/Caskroom/docker/.metadata/2.0.0.3-ce-mac81,31259/20190606033012.158/Casks/docker.rb /usr/local/Caskroom/gimp/.metadata/2.10.10/20190531015556.562/Casks/gimp.rb /usr/local/Caskroom/google-chrome/.metadata/74.0.3729.169/20190601060424.055/Casks/google-chrome.rb /usr/local/Caskroom/inkscape/.metadata/0.92.2-1,11269/20190531015635.137/Casks/inkscape.rb /usr/local/Caskroom/intellij-idea-ce/.metadata/2019.2,192.5728.98/20190819144504.990/Casks/intellij-idea-ce.rb /usr/local/Caskroom/phpstorm/.metadata/2019.1.3,191.7479.51/20190619221705.836/Casks/phpstorm.rb /usr/local/Caskroom/vagrant/.metadata/2.2.4/20190604025414.982/Casks/vagrant.rb /usr/local/Caskroom/virtualbox/.metadata/6.0.8,130520/20190604025358.326/Casks/virtualbox.rb /usr/local/Caskroom/visual-studio-code/.metadata/1.34.0,a622c65b2c713c890fcf4fbf07cf34049d5fe758/20190531023723.504/Casks/visual-studio-code.rb
Code language: Bash (bash)

ファイルがたくさん表示されているのはわかるけど、読みにくいね

-pinrt0 オプションをやめると、1行1ファイル表示された

$ /usr/bin/find "$(brew --prefix)/Caskroom/"*'/.metadata' -type f -name '*.rb' /usr/local/Caskroom/android-studio/.metadata/3.4.1.0,183.5522156/20190603094537.564/Casks/android-studio.rb /usr/local/Caskroom/apache-couchdb/.metadata/3.1.0/20200515015701.723/Casks/apache-couchdb.rb /usr/local/Caskroom/db-browser-for-sqlite/.metadata/3.11.2/20191107133732.184/Casks/db-browser-for-sqlite.rb /usr/local/Caskroom/diffmerge/.metadata/4.2.1.1013/20190607031447.313/Casks/diffmerge.rb /usr/local/Caskroom/docker/.metadata/2.0.0.3-ce-mac81,31259/20190606033012.158/Casks/docker.rb /usr/local/Caskroom/gimp/.metadata/2.10.10/20190531015556.562/Casks/gimp.rb /usr/local/Caskroom/google-chrome/.metadata/74.0.3729.169/20190601060424.055/Casks/google-chrome.rb /usr/local/Caskroom/inkscape/.metadata/0.92.2-1,11269/20190531015635.137/Casks/inkscape.rb /usr/local/Caskroom/intellij-idea-ce/.metadata/2019.2,192.5728.98/20190819144504.990/Casks/intellij-idea-ce.rb /usr/local/Caskroom/phpstorm/.metadata/2019.1.3,191.7479.51/20190619221705.836/Casks/phpstorm.rb /usr/local/Caskroom/vagrant/.metadata/2.2.4/20190604025414.982/Casks/vagrant.rb /usr/local/Caskroom/virtualbox/.metadata/6.0.8,130520/20190604025358.326/Casks/virtualbox.rb /usr/local/Caskroom/visual-studio-code/.metadata/1.34.0,a622c65b2c713c890fcf4fbf07cf34049d5fe758/20190531023723.504/Casks/visual-studio-code.rb
Code language: Bash (bash)

お!inkscapeのファイルがあるね、なかみを見てみよう

$ cat /usr/local/Caskroom/inkscape/.metadata/0.92.2-1,11269/20190531015635.137/Casks/inkscape.rb cask 'inkscape' do version '0.92.2-1,11269' sha256 'faece7a9a5fa9db7724b0c761f7f2014676d00ef8b90a0ef506fa39d09209fea' url "https://inkscape.org/gallery/item/#{version.after_comma}/Inkscape-#{version.before_comma}-x11-10.7-x86_64.dmg" name 'Inkscape' homepage 'https://inkscape.org/' depends_on x11: true app 'Inkscape.app' binary "#{appdir}/Inkscape.app/Contents/Resources/bin/inkscape" zap trash: '~/.inkscape-etc' end
Code language: Bash (bash)

https://github.com/Homebrew/homebrew-cask/blob/master/Casks/inkscape.rb の バージョン0.92.2のファイルみたいだね

sedの置換を試してみよると、10行目の

depends_on x11: true

が削除されるんだね

$ sed '/depends_on x11:/d' /usr/local/Caskroom/inkscape/.metadata/0.92.2-1,11269/20190531015635.137/Casks/inkscape.rb cask 'inkscape' do version '0.92.2-1,11269' sha256 'faece7a9a5fa9db7724b0c761f7f2014676d00ef8b90a0ef506fa39d09209fea' url "https://inkscape.org/gallery/item/#{version.after_comma}/Inkscape-#{version.before_comma}-x11-10.7-x86_64.dmg" name 'Inkscape' homepage 'https://inkscape.org/' app 'Inkscape.app' binary "#{appdir}/Inkscape.app/Contents/Resources/bin/inkscape" zap trash: '~/.inkscape-etc' end
Code language: Bash (bash)

他に depends_on x11: true のあるファイルがあるか調べると、

$ /usr/bin/find "$(brew --prefix)/Caskroom/"*'/.metadata' -type f -name '*.rb' -print0 | xargs -0 grep "depends_on x11" /usr/local/Caskroom/inkscape/.metadata/0.92.2-1,11269/20190531015635.137/Casks/inkscape.rb: depends_on x11: true
Code language: Bash (bash)

このファイルだけだ。

このファイルだけをsed置換しよう。

$ sed -i '' '/depends_on x11:/d' /usr/local/Caskroom/inkscape/.metadata/0.92.2-1,11269/20190531015635.137/Casks/inkscape.rb
Code language: Bash (bash)

置換後のファイルを見てみると、

$ cat /usr/local/Caskroom/inkscape/.metadata/0.92.2-1,11269/20190531015635.137/Casks/inkscape.rb cask 'inkscape' do version '0.92.2-1,11269' sha256 'faece7a9a5fa9db7724b0c761f7f2014676d00ef8b90a0ef506fa39d09209fea' url "https://inkscape.org/gallery/item/#{version.after_comma}/Inkscape-#{version.before_comma}-x11-10.7-x86_64.dmg" name 'Inkscape' homepage 'https://inkscape.org/' app 'Inkscape.app' binary "#{appdir}/Inkscape.app/Contents/Resources/bin/inkscape" zap trash: '~/.inkscape-etc' end
Code language: Bash (bash)

無事、

depends_on x11: true

が削除されてるね。

さて、brew upgradeできるかな?

$ brew upgrade pdating Homebrew... ==> Casks with 'auto_updates' or 'version :latest' will not be upgraded; pass `--greedy` to upgrade them. ==> Upgrading 5 outdated packages: apache-couchdb 3.1.0 -> 3.1.1 db-browser-for-sqlite 3.11.2 -> 3.12.2 inkscape 0.92.2-1,11269 -> 1.1 vagrant 2.2.4 -> 2.2.16 virtualbox 6.0.8,130520 -> 6.1.22,144080
Code language: JavaScript (javascript)

brew upgrade始まった!

久しぶりのbrew upgradeだから、半日かかったよ

ときどき brew upgrade しないとね

タイトルとURLをコピーしました