Updating Homebrew after a recent change is generating an error message for any command:
cannot load such file -- api
Background
After running brew update
, the following error is appearing for any command, including brew install ...
, brew list
, even brew help
:
/usr/local/Homebrew/Library/Homebrew/utils/analytics.rb:7:in `require': cannot load such file -- api (LoadError)
The referenced line was changed in this update.
Solution
The easiest solution is to reinstall Homebrew–this does not affect installed packages, and runs quickly. Visit the Homebrew home page to copy the install script command/URL (omitted here in case of future change).
After reinstallation, Homebrew commands should work normally. 🤞