根据错误信息,Homebrew 无法在 GitHub 上搜索已删除的公式,并且提示您需要创建一个个人访问令牌。请按照以下步骤解决此问题:
- 打开终端并执行以下命令以清除 macOS 中的 GitHub 凭据:
printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
转到 https://github.com/settings/tokens/new?scopes=gist,repo,workflow&description=Homebrew 并创建一个新的 GitHub 个人访问令牌。
在“Token description”字段中输入任何描述性文本以标识此 token。
在“Select scopes”部分中选择 “gist”,“repo”和“workflow”。
点击 “Generate token” 按钮以生成新的个人访问令牌。
复制生成的令牌值(字符串)。
在终端中输入以下命令将该 token 添加到您的 shell 配置文件(例如 ~/.zshrc)中:
echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc
将上面命令中 your_token_here 替换为您在第五步中复制的 token 值。
重新加载 shell 配置文件使更改生效:
source ~/.zshrc
- 现在尝试再次运行 Homebrew 命令,应该不会再看到先前出现的错误信息。