LoginSignup
18
18

More than 5 years have passed since last update.

brew search して GitHub API rate limit で怒られたときの対処方法

Posted at

brew search を何度も実行していると、以下のように怒られるときがあります。

$ brew search apache
apache-activemq                       apache-fop                            apache-spark                          homebrew/versions/apache-spark131
apache-archiva                        apache-forrest                        apachetop                             homebrew/versions/apache-spark141
apache-drill                          apache-opennlp                        homebrew/versions/apache-spark121
Error: GitHub API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
Try again in 28 minutes 13 seconds, or create a personal access token:
  https://github.com/settings/tokens/new?scopes=&description=Homebrew
and then set the token as: HOMEBREW_GITHUB_API_TOKEN

GitHub API へのアクセス数がリミットを超えたときにこのエラーが出るようです。

回避するには、エラーメッセージにある通り、自分の GitHub アカウントでアクセストークンを作ります。

https://github.com/settings/tokens/new?scopes=&description=Homebrew へアクセスして、ログインします。

そのまま、何もチェックせずに Generate Token ボタンを押してトークンを作成します。

作成したトークン(文字列)をコピーし、自環境にて環境変数を設定します。.bashrc とかに書いてあげるとよいでしょう。

export HOMEBREW_GITHUB_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxx

再度 brew search を実行して、エラーで怒られなければ設定は成功です。

Homebrew 公式の説明はこちら:
https://github.com/Homebrew/homebrew/blob/d28a4ba62d17914982ae86ebef1e021cc242eb36/Library/Homebrew/manpages/brew.1.md

18
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
18