Fix Binary Path Order on macOS with Homebrew and mise
Goal
Make the shell find Homebrew tools and mise-managed runtimes before the old binaries macOS ships in /usr/bin, and switch Python or Node versions automatically per project.
Prerequisites
- Homebrew (standalone tools such as
git,stow,fzf). - mise, the polyglot version manager that succeeds asdf (
brew install mise). - zsh as the login shell. In Ghostty,
command = /bin/zsh --loginmakes each window a login shell, so/etc/zprofileand~/.zshrcare read every time.
Steps
- See the current lookup order, searched top to bottom:
Ifecho $PATH | tr ':' '\n'/usr/bincomes before/opt/homebrew/bin, the system versions ofgit,pythonorcurlwin. - Put Homebrew first and activate mise near the top of
~/.zshrc:eval "$(/opt/homebrew/bin/brew shellenv)" # Homebrew's bin and sbin, in front if command -v mise >/dev/null; then eval "$(mise activate zsh)" # mise prepends the active runtimes fi - Reload the shell:
exec zsh. - Install a global runtime and per-project versions:
mise use --global python@3.13 # default everywhere cd ~/DevSecMLOps/project-a && mise use python@3.11 # writes mise.toml in the project
mise Commands
| Goal | Command |
|---|---|
| List installable versions | mise ls-remote python |
| Only one major line | mise ls-remote python@3.12 |
| Installed versions | mise ls |
| Install and pin for this project | mise use python@3.12.8 |
| Install and pin globally | mise use --global python@3.12.8 |
Verify
-
echo $PATH | tr ':' '\n'lists…/mise/installs/python/<version>/bin, then/opt/homebrew/bin, before/usr/bin. -
which pythonpoints into~/.local/share/mise/installs/, not/usr/bin. -
cdinto project-a and project-b:python --versionchanges.
Troubleshooting
which pythonstill shows/usr/bin/python3: theevallines run after something that resetsPATH; move them up, or check/etc/zprofile, which macOS'spath_helperruns first.- Tools inside IDEs or scripts don't see mise versions:
mise activateworks in interactive shells; for non-interactive use add the shims directory instead:export PATH="$HOME/.local/share/mise/shims:$PATH".
References
- mise documentation: Getting started - installation and
mise activate. - mise documentation: Shims - activate vs shims.
- Homebrew documentation: brew shellenv - the environment Homebrew sets.
- Troubleshooting Python Global Version Issues with asdf - the asdf problems that led me to mise.
- Programming Languages MOC - hub for language tooling.