From b86a99da177ad40de2906582c65a3d9f53b73c60 Mon Sep 17 00:00:00 2001 From: Ininsico <157946121+Ininsico@users.noreply.github.com> Date: Mon, 1 Jun 2026 13:55:38 +0500 Subject: [PATCH] fix(brew): add sbin to PATH (#13780) --- plugins/brew/README.md | 6 ++++++ plugins/brew/brew.plugin.zsh | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/plugins/brew/README.md b/plugins/brew/README.md index 07c387380..5e3e3fab6 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -17,6 +17,12 @@ If `brew` is not found in the PATH, this plugin will attempt to find it in commo In case you installed `brew` in a non-common location, you can still set `BREW_LOCATION` variable pointing to the `brew` binary before sourcing `oh-my-zsh.sh` and it'll set up the environment. +### sbin directory + +This plugin also adds `$HOMEBREW_PREFIX/sbin` to the PATH if the directory exists and isn't already present. +Some Homebrew formulae (e.g. `mtr`) install executables to `sbin`, which `brew doctor` checks for. This +ensures the `bdr` alias runs without warnings. + ## Aliases | Alias | Command | Description | diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 7d5db2068..45cd89f44 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -30,6 +30,16 @@ if [[ -z "$HOMEBREW_PREFIX" ]]; then export HOMEBREW_PREFIX="$(brew --prefix)" fi +# Add Homebrew sbin to PATH if it exists and is not already in PATH. +# Homebrew's shellenv only adds bin directories, not sbin. Some formulae +# (e.g. mtr) install executables to sbin, and brew doctor warns if it's +# missing from PATH. +if [[ -d "$HOMEBREW_PREFIX/sbin" ]]; then + if [[ ! "$PATH" == *"$HOMEBREW_PREFIX/sbin"* ]]; then + export PATH="$HOMEBREW_PREFIX/sbin:$PATH" + fi +fi + if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions") fi