Closed gpanders closed 5 years ago
Yep, my setup is:
login -fp myusername
PATH
is set explicitly in ~/.zshenv
, not relying on any other startup files (it just builds on the very standard /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
, adding other directories if present, e.g. ~/.rbenv/shims
)The easy solution would be to do all of my
PATH
setup in.zprofile
so that it happens afterpath_helper
is called. But then that would violate the recommendations of this plugin.
I suspect that I should stop recommending any particular scheme or "ideal" for the startup files. I even thought about removing the warning recently. While there are reasons to avoid -l
and -i
, most notably the shell startup time and incidental terminal output, I think most people just don't care, and simply want the PATH
that comes with -l
+ -i
.
In fairness it's not just your recommendation but I think it is even the recommendation of zsh that PATH manipulation should go in .zshenv. Unfortunately, most distributions (macOS included) seem to not honor the intended usage of the zsh/bash init file hierarchy.
Thanks for the quick reply. I'll go ahead and close this since it seems like there isn't really a "right" answer here.
Yup. FWIW, setting the full path explicitly has been pretty foolproof for me. And note that I imaging you can always call path_helper
yourself at any convenient point.
First let me say I know there are a few open issues with titles similar to mine, but I didn't see my particular question addressed in any of those.
I am following the recommended advice and putting all of my
PATH
setup in my~/.zshenv
and removed the-i
and-l
flags fromexec-path-from-shell-arguments
. In Emacs, this all works fine.However, this causes problem when I use my terminal emulator, which does act as a login shell. In macOS the default
/etc/zprofile
file calls a program calledpath_helper
that modifies your path in login shells by reading paths from/etc/paths
and/etc/paths.d
. Because I set up myPATH
in.zshenv
(which is sourced before/etc/zprofile
and.zprofile
) my path gets messed up. Here's a (minimal) example of what I mean:.zshenv:
/etc/paths:
.zshenv
, my path is$HOME/.pyenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
/etc/zprofile
is sourced, which calls/usr/libexec/path_helper
, which reads/etc/paths
and changes my PATH to/usr/bin:/bin:/usr/sbin:/sbin:$HOME/.pyenv/bin:/usr/local/bin
.zprofile
is sourced, but because I removed allPATH
modification into.zshenv
, no further changes happenNow,
/usr/bin
is first in my path ahead of both pyenv and/usr/local/bin
, which is obviously not what I want (since my installed packages are shadowed by the macOS default binaries).The easy solution would be to do all of my
PATH
setup in.zprofile
so that it happens afterpath_helper
is called. But then that would violate the recommendations of this plugin.Since I know you also use zsh and I think you also use macOS(?), I'm wondering how you handle this.