macOS has path_helper utility that rearranges shell PATH environment causing all kinds of problems. The path_helper is run at zsh startup from /etc/zprofile and you can just comment it out there to disable safely.
The issue is that macOS updates overwrite /etc/zprofile. This script automatically comments out path_helper in /etc/zprofile and being called at zsh startup it watches that file, and if change is detected, prompts to automatically disable the path_helper again.
-
Copy
zsh_path_helper_disable.zshto your home directory:cp zsh_path_helper_disable.zsh "$HOME/.zsh_path_helper_disable" -
Add to your
~/.zshenv:echo '[ -f "$HOME/.zsh_path_helper_disable" ] && . "$HOME/.zsh_path_helper_disable"' >> ~/.zshenv
or insert this manually in the beginnign of ~/.zshenv:
[ -f "$HOME/.zsh_path_helper_disable" ] && . "$HOME/.zsh_path_helper_disable"
-
Open a new terminal or run
source ~/.zshenvto activate.
- On each shell startup, the script checks if
/etc/zprofilehas changed (usingcrc32). - If
/etc/zprofilehas not been checked or has changed, it prompts you to comment outpath_helperin/etc/zprofile(requires sudo). - If you confirm, it comments out the relevant line, updates the checksum, and notifies you to reopen your shell.
- Operations done using
sudoso you will be asked to authenticate - backup
/etc/zprofile.bakis automatically created
-
Remove the line from your
~/.zshenv. -
Delete
.zsh_path_helper_disableand.zsh_path_helper_disable_statefrom your home directory:rm ~/.zsh_path_helper_disable rm ~/.zsh_path_helper_disable_state
-
Optionally restore
/etc/zprofile:sudo cp /etc/zprofile.bak /etc/zprofile