Fix Binary Path Order on macOS with Homebrew and mise

In progress

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 --login makes each window a login shell, so /etc/zprofile and ~/.zshrc are read every time.

Steps

  1. See the current lookup order, searched top to bottom:
    echo $PATH | tr ':' '\n'
    
    If /usr/bin comes before /opt/homebrew/bin, the system versions of git, python or curl win.
  2. 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
    
  3. Reload the shell: exec zsh.
  4. 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 python points into ~/.local/share/mise/installs/, not /usr/bin.
  • cd into project-a and project-b: python --version changes.

Troubleshooting

  • which python still shows /usr/bin/python3: the eval lines run after something that resets PATH; move them up, or check /etc/zprofile, which macOS's path_helper runs first.
  • Tools inside IDEs or scripts don't see mise versions: mise activate works in interactive shells; for non-interactive use add the shims directory instead: export PATH="$HOME/.local/share/mise/shims:$PATH".

References