Homebrew
Quick write-up about Homebrew
AI-powered write-up, verify yourself!
This is one of those things, most developers (including me) just install and use without thinking about it. So, just doing quick-AI write-up to learn it.
What is Homebrew?
Homebrew is a package manager for macOS (and Linux) that lets you easily install software from the command line. Think of it like an app store for your terminal - instead of downloading software from websites, extracting files, and manually installing them, you can just type something like brew install python
and Homebrew handles all the downloading, installing, and setting up for you.
The name comes from the idea of "brewing" your own software setup, and it's become the standard way most Mac developers manage their development tools.
Is Homebrew pre-installed on macOS?
No, Homebrew is not pre-installed on macOS. You need to install it yourself using this command in Terminal:
How do I check if Homebrew is installed?
Run this command in Terminal:
If it shows a version number, Homebrew is installed and working.
Basic Homebrew Commands
brew install [package]
- Install a packagebrew uninstall [package]
- Remove a packagebrew update
- Update Homebrew itselfbrew upgrade
- Update all installed packagesbrew upgrade [package]
- Update a specific packagebrew list
- Show all installed packagesbrew search [term]
- Search for available packagesbrew info [package]
- Get detailed information about a packagebrew doctor
- Check for common issues and problems
What's the difference between brew install
and brew install --cask
?
brew install [package]
- Installs command-line tools and libraries (like git, python, node)brew install --cask [package]
- Installs GUI applications (like Chrome, VS Code, Slack)
For example:
brew install git
- Installs the Git command-line toolbrew install --cask google-chrome
- Installs Google Chrome browser
Where does Homebrew install packages?
Homebrew installs packages in /opt/homebrew
on Apple Silicon Macs (M1/M2) and /usr/local
on Intel Macs. It creates symbolic links in /opt/homebrew/bin
or /usr/local/bin
so you can use the commands from anywhere.
How do I update Homebrew and my packages?
- Update Homebrew itself:
brew update
- Update all installed packages:
brew upgrade
- Update a specific package:
brew upgrade [package]
It's good practice to run brew update
before installing new packages to ensure you have the latest package information.
How do I uninstall Homebrew completely?
Run this command in Terminal:
What should I do if I get permission errors?
Never use sudo
with Homebrew commands. If you're getting permission errors:
- Make sure you own the Homebrew directories:
sudo chown -R $(whoami) /opt/homebrew
(or/usr/local
on Intel Macs) - Run
brew doctor
to diagnose issues - If problems persist, consider reinstalling Homebrew
How do I see what packages I have installed?
brew list
- Show all installed packagesbrew list --cask
- Show only GUI applications (casks)brew deps [package]
- Show dependencies for a specific package
Can I install a specific version of a package?
Homebrew typically only maintains the latest version of packages. For older versions, you might need to:
- Use version managers (like
nvm
for Node.js,pyenv
for Python) - Install from source
- Use Homebrew's versioned formulas when available (like
python@3.9
)
What's a Homebrew formula vs. a cask?
- Formula: Recipe for installing command-line tools and libraries
- Cask: Extension for installing GUI applications
How do I troubleshoot Homebrew issues?
- Run
brew doctor
- This checks for common problems - Run
brew update
- Ensures you have the latest package information - Check the Homebrew GitHub issues page
- Look at the installation logs for specific error messages
Common Homebrew Commands Cheat Sheet
Best Practices
- Run
brew update
regularly to keep package information current - Use
brew upgrade
periodically to update installed packages - Run
brew cleanup
occasionally to remove old versions and free up space - Use
brew doctor
if you encounter any issues - Don't use
sudo
with Homebrew commands - Keep your macOS up to date for best compatibility
Getting Help
brew help
- Shows general helpbrew help [command]
- Shows help for a specific command- Visit brew.sh for official documentation
- Check the Homebrew GitHub repository for issues and discussions
Last updated on