13

My setup is zsh 5.0.5 in arch linux

I have set the PATH variable as below in .zshenv

typeset -U path
path=(~/bin $path)
DW=$HOME/Downloads

but it didn't work. print $PATH shows only

/usr/local/bin:/usr/bin:/usr/bin/vendor_perl:/usr/bin/core_perl

.zshenv was read, because I could see DW variable is set. Only PATH variable isn't set. And what I don't understand is, after rename the .zshenv to .zshrc, PATH variable just works as intended.

Need any special treatment setting environment variables in .zshenv?

3 Answers 3

24

I just encountered this problem myself, and the real answer is that Zsh on Arch sources /etc/profile – which overwrites and exports PATHafter having sourced ~/.zshenv.

See: https://wiki.archlinux.org/index.php/Zsh#Configuration_files

2
  • 11
    Wow. Same on MacOSX, btw. Very unexpected behaviour - at least for me. Feb 3, 2016 at 21:11
  • 2
    I just had the same problem on Arch Linux. The culprit is /etc/zsh/zprofile file, which says emulate sh -c 'source /etc/profile'. And the reason I found it was that my SublimeLinter couldn't correctly read PERL5LIB!
    – rubikonx9
    Mar 24, 2016 at 7:56
1

It seems that when you have macos or some linux distros there is a canonical solution to the problem which involves /etc/paths or /etc/paths.d. You should be letting /usr/libexec/path_helper construct your path for you using configuration files.

This immediately solved the problem in all places for me.

1
-1

I've got the same problem. The cause was my .zshrc (fresh install of oh-my-zsh) override PATH (ignoring existing value):

export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl"

To fix, I comment the line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.