📘

ひさびさにbrew使ったら更新でちょっとハマった話

2023/10/10に公開

ひさびさにbrewで検索を実行したら↓なエラーが

% brew search hoge
Warning: Error searching on GitHub: GitHub API Error: Requires authentication
The GitHub credentials in the macOS keychain may be invalid.
Clear them with:
  printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
Create a GitHub personal access token:
    https://github.com/settings/tokens/new?scopes=gist,repo,workflow&description=Homebrew
  echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc

Github Token設定してもいいんだけど...と思って検索してみたら
こんな記事が(安定のDevelopers IO→いつもお世話になっております)
https://dev.classmethod.jp/articles/202304-brew-search-changed/

更新すれば良さそうなので

% brew update

が、エラーが出てたので
Homebrew自体の問題を確認

% brew doctor
Warning: You have an unnecessary local Cask tap.
This can cause problems installing up-to-date casks.
Please remove it by running:
  brew untap homebrew/cask

Warning: You have an unnecessary local Core tap!
This can cause problems installing up-to-date formulae.
Please remove it by running:
 brew untap homebrew/core

メッセージ通りに実行

% brew untap homebrew/cask
% brew untap homebrew/core

もう一回

% brew update
fatal: couldn't find remote ref refs/heads/master
Error: Fetching /opt/homebrew/Library/Taps/dart-lang/homebrew-dart failed!
Error: Some taps failed to update!
The following taps can not read their remote branches:
  dart-lang/dart
This is happening because the remote branch was renamed or deleted.
Reset taps to point to the correct remote branches by running `brew tap --repair`

使ってるパッケージのブランチが変更になってる模様

% brew tap --repair
 :
==> dart-lang/dart: changed default branch name from master to main!

向き先もなおせたので再度

% brew update

エラー出なくなったのでパッケージも更新

% brew upgrade

なおた

あと不要なfomula削除(やらなくても良い)
ちなみに--dry-runオプションも使える

% brew autoremove

Discussion