first off i'm not really sure if it should be called a bug or a feature. zsh's system-wide config files(particularly /etc/profile.env source'ed by /etc/zsh/zprofile) override user defined settings like $PATH by default installation. This happenes due to that /etc/profile.env defines vars from scratch and that it's source'ed after ~/.zshenv where users basic settings go into. i know that everything in gentoo is up to users and it's not a big deal to modify the config files by themself after installation. but still this problem might confuse newbies because $PATH and such defined in ~/.zshenv are overriden. This problem is only occured when zsh is invoked as login shell because zprofile is only read by login shells. startup files of zsh as login shell is shown below in order. /etc/zsh/zshenv -> ~/.zshenv -> /etc/zsh/zprofile -> ~/.zprofile -> ... i suggest moving current content of /etc/zsh/zprofile to /etc/zsh/zshenv Reproducible: Always
I am not sure that is a great idea as all the commands will be run on each invocation of zsh which seem wasteful.
hi, Do you mean contents of /etc/zsh/zprofile by "all the commands"? If so let's see /etc/{zsh/zprofile,profile.env}. These two files set important environment variables of system such as PATH, MANPATH and so. I think those env vars should be set for both login and non-login shells. Consequently the best place for those env vars is zshenv rather than zprofile, as i mentioned which is only read by login shells. For reference i attached Debian's /etc/zsh/{zshenv,zprofile}.
Created attachment 257127 [details] zshenv of debian's zsh-4.3.6
Created attachment 257129 [details] zprofile of debian's zsh-4.3.6
neither of the debian files are setting up all the environmental variables as you suggest to do, the only thing set up in the zshenv is PATH in the case that it has not been properly initialized, this is not the same as initializing all the environmental as is done in the gentoo zprofile
From what I can tell debian prefers the use of pam_env for setting up environmental variables
hi, sry if debian's example was not appropriate. I should have taken exherbo instead. My suggestion to move zshenv to zprofile was one of solutions. The problem that I'd like to point out is exactly what the summary says. If one uses ~/.zshenv to set PATH and umask these settings will eventually discarded by /etc/zsh/zprofile. This behaviour doesn't look nice as a default installation state. Or is it only me to use ~/.zshenv? If so please ignore me then close the bug:) (I try to stick to zshenv instead of zprofile because environment inheritance doesn't always work as expected in some case when using a display manager with tmux/screen which is first run by session manager.)
This bug is a dup of bug 19924, isn't it?
*** This bug has been marked as a duplicate of bug 19924 ***
(In reply to comment #7) > Or is it only me to use ~/.zshenv? If so please ignore me then close the bug:) > (I try to stick to zshenv instead of zprofile because environment inheritance > doesn't always work as expected in some case when using a display manager with > tmux/screen which is first run by session manager.) No, you aren't. stuff you'd like to have in non-interactive and interactive shells belong to .zshenv, like PATH (including users modifications), LC_* LANG and so on. stuff you only need in interactive shells, like PS1, aliases, convenience functions, HISTFILE, the whole zsh-prompt setup belongs to zprofile/.zshrc