Homebrew Caskのコマンドがエラーで動かなくなった時の解決方法
Macのアプリ管理はHomebrew Caskでやっているんですが、
先日インストール一覧を確認しようとしたこんなエラーが出ました。
Error: wrong number of arguments (1 for 0) while loading '/usr/local/Library/Taps/caskroom/homebrew-cask/Casks/alfred.rb' Please report this bug: https://github.com/caskroom/homebrew-cask/issues <main>:5:in `name' <main>:5:in `<class:Alfred>' <main>:in `<main>' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/source/path_base.rb:55:in `eval' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/source/path_base.rb:55:in `rescue in load' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/source/path_base.rb:52:in `load' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask.rb:120:in `load' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/scopes.rb:55:in `block in installed' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/scopes.rb:49:in `map' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/scopes.rb:49:in `installed' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/cli/list.rb:52:in `list_installed' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/cli/list.rb:10:in `run' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/cli.rb:81:in `run_command' /usr/local/Cellar/brew-cask/0.43.1/rubylib/cask/cli.rb:121:in `process' /usr/local/bin/brew-cask.rb:42:in `<top (required)>' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' /usr/local/Library/brew.rb:58:in `require?' /usr/local/Library/brew.rb:141:in `<main>'
とりあえずいつもの感じでアップデートと診断コマンドを実行したら
necoyama3:~ $brew update && brew doctor Already up-to-date. Your system is ready to brew. necoyama3:~ $
てな感じで正常に動作してるので、
もう一度「brew cask list」コマンドで一覧を見てみようとしたら同じエラーが出ました。
そこでおとなしくエラーログにあるissuesを見に行って、
最終的に以下のコマンドを実行したら正常に動作するようになりました。
brew update && brew upgrade brew-cask && brew cleanup && brew cask cleanup
やっぱり最初からエラーログのissues見に行くほうが賢いですね。