prezto: The notice about `path_helper` on OS X is incorrect
This:
If you have administrator privileges, you must fix an Apple-introduced problem in Mac OS X 10.5 Leopard by executing the following command, or BASH and Zsh will have the wrong PATH when executed non-interactively.
sudo chmod ugo-x /usr/libexec/path_helper
Is incorrect. Users shouldn’t disable path_helper
.
The problem is OS X is that it comes with /etc/zshenv
that uses path_helper
. However, /etc/zshenv
gets sourced for every zsh shell, even non-interactive. To put a stop to that, simply:
sudo mv /etc/{zshenv,zprofile}
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Reactions: 1
- Comments: 31 (14 by maintainers)
Commits related to this issue
- [Fix #381] Revise the path_helper workaround Instead of disabling path_helper, move /etc/zshenv to /etc/zprofile. Then disable global rc files in ~/.zshenv. — committed to sorin-ionescu/prezto by sorin-ionescu 11 years ago
- [Fix #381] Remove the path_helper workaround — committed to sorin-ionescu/prezto by sorin-ionescu 11 years ago
- Merge https://github.com/sorin-ionescu/prezto into caleb * https://github.com/sorin-ionescu/prezto: Add Emacs module [Fix #396] Remove the osx trash function [Fix #398] Manually set locale [F... — committed to Bklyn/prezto by deleted user 11 years ago
- [Fix #381] Remove the path_helper workaround — committed to adamwalz/prezto by sorin-ionescu 11 years ago
- [Fix #381] Remove the path_helper workaround — committed to adamwalz/prezto by sorin-ionescu 11 years ago
- [Fix #381] Remove the path_helper workaround — committed to adamwalz/prezto by sorin-ionescu 11 years ago
- [Fix #381] Remove the path_helper workaround — committed to linuslundahl/prezto by sorin-ionescu 11 years ago
- Fix OSX zsh environment bug * This a known bug discussed [here](https://github.com/sorin-ionescu/prezto/issues/381). — committed to geoffharcourt/laptop by deleted user 11 years ago
- [Fix #381] Remove the path_helper workaround — committed to lildude/prezto by sorin-ionescu 11 years ago
- [Fix #381] Remove the path_helper workaround — committed to lackac/prezto by sorin-ionescu 11 years ago
- Merge pull request #381 from jozefizso/license_middleman Added license to middleman — committed to kodelint/prezto by nicoulaj 8 years ago
- Revert "Disable path helper" Because 1. This isn't the right way to fix the issue with OSX/homebrew/zsh, see https://github.com/sorin-ionescu/prezto/issues/381 for more info... 2. ...and zsh is no ... — committed to mocoso/dotfiles by mocoso 7 years ago
- Update submodules Submodule changes to be committed: * modules/autosuggestions/external 15931f0...c7d4a85 (1): > Merge pull request #299 from zsh-users/develop * modules/base16/base16-shell 8... — committed to Gee-Bee/prezto by Gee-Bee 6 years ago
- zsh: fix $PATH (what a mess), hopefully once & for all. So, I was trying to play with https://pax.js.org/. After I installed it & when I tried to run `pax` I got a totally different command with the ... — committed to ahmedelgabri/dotfiles by ahmedelgabri 6 years ago
- PATH設定を.zprofileに戻す .zshenvでPATH設定をすべきではないという考えがあることを知った。 ことの始まりはosxやmacOSが/etc/zprofileで`path_helper`を呼び出し、 .zshenvであくせく組んだPATHを叩き壊したことから。 事実、コマンドを実行したときなどの非対話型な場面において PATHを通す必要があるかというと、ないはず。 せいぜい... — committed to yajamon/dotfiles by yajamon 4 years ago
- Update submodules Submodule changes to be committed: * modules/autosuggestions/external 15931f0...c7d4a85 (1): > Merge pull request #299 from zsh-users/develop * modules/base16/base16-shell 8... — committed to Gee-Bee/prezto by Gee-Bee 6 years ago
- [Fix #381] Remove the path_helper workaround — committed to rooney/prezto by sorin-ionescu 11 years ago
- [Fix #381] Remove the path_helper workaround — committed to RIT80/prezto by deleted user 11 years ago
- [Fix #381] Remove the path_helper workaround — committed to RIT80/prezto by RIT80 11 years ago
@mislav, I understand how it works. It’s broken.
I also understand that having it enabled causes problems. You forget the path set in ~/.MacOSX/environment.plist, which is needed for GUI apps, and Terminal.app, being a GUI app, will get that environment before it launches a shell subprocesses.
path_helper
reorders the PATH entries set in environment.plist, which causes GUI programs to fail when they execute their scripts via a shell subprocess. A good example is any editor that depends on Exuberant Ctags.path_helper
reorders the PATH entries and /usr/bin/ctags gets executed instead of Exuberant Ctags that is installed elsewhere. The editor complains that the wrong ctags is installed.If I don’t set the PATH in environment.plist for GUI apps, then they complain that they can’t find programs.
Setting PATH on Mac OS X is a mess, and
path_helper
doesn’t help.It’s too late to modify PATH in ~/.zshrc for essential path entries that must exist for non-interactive shells. Hence why ~/.zshenv exists. There is a README in the runcoms directory that explains all the Zsh files.
Except for the Ruby, Python, and Perl paths that are added by their respective Prezto modules, the rest of the home directory path entries are set in ~/.zshenv, which is a copy of the runcoms/zshenv file.
path_helper
is not needed. Apple could have implemented /etc/paths.d properly by using shell code, just like I have, but it looks like they spent 10 minutes to write a broken C program instead.path_helper
is broken. Dancing around the issue causes nothing but frustration. The only real solution, without editing /etc shell init files, is to replace the Apple suppliedpath_helper
with a fixed one that doesn’t rearrange path entries. It’s a simple C program.Anyway, for anybody who’ll land here too, here is a workaround:
in
.zshenv
: before customizingPATH
:At the end of
.zshenv
:Create a
.zprofile
(I don’t usually have one):Now everything works as intended.
@pdemarti, if we consider unix shell initialization, then we may come to conclusion that /etc/zprofile is not called in some cases. At least in the case when we
In addition, it slows down the terminal session loading process.
So, I suppose the correct solution would be NOT to include
into
~/.zshenv
, but to savePATH
at the END of~/.zshenv
as you, indeed, did.
Then, you just need to set
PATH
in~/.zprofile
, such that it would beIn this case you just prepend your path from resulting
PATH
from~/.zshenv
to thePATH
that was mutated by/etc/zprofile
.In order to remove duplications and not just merge two paths you can use instead of this
this script:
Reordering entries in /etc/paths realy feels like a less intrusive way of fixing this.
I’ve searched for results in the past year and it doesn’t seem like people have real issues with it. Support questions on forums/mailing lists are from people that struggle to find out how to edit their PATH and what’s the right configuration file for that. The Hackernews comment about path_helper says that it used to be slow, but that’s not the case since the C rewrite. As for the supposed bugs it has, I haven’t found any real report of someone finding a bug with it.
Here’s what
path_helper
does, and is designed to do: It takes the current PATH and adds global entries to it, moving them to front if they already exist in PATH. Yes, it reorders entries in the PATH, because it was designed to run as the first thing in a login shell, not as the last. You’re just using it wrong, and then claim frustration with the tool.@telemachus: People blindly follow instructions, especially when copy/pasting from README files, and forget that they do so. Especially when they don’t know what
path_helper
is (and most don’t). A Prezto user might switch back to bash and wonder why their system doesn’t work like before. They won’t remember tochmod +x path_helper
Agreed. And I am advocating the least invasive way to fix the problem here: let
path_helper
do its thing and then customize it further to your needs.Editors like Vim or Emacs start these shells when executing shell commands (i.e.
M-x compile
orM-x grep
in Emacs). Git, too, starts such a shell to start an Editor. Withpath_helper enabled,
git commitwill always start OS X builtin
/usr/bin/vim/even if there is a custom installation in
/usr/local/bin` (e.g. via Homebrew).Yes.
path_helper
was only flawed in zsh, due to misplaced/etc/zshenv
. Bash sources/etc/profile
(which usespath_helper
) only for login shells, not for other interactive or non-interactive shells.There’s nothing wrong with
path_helper
per se.