You are not logged in.

#1 2014-04-29 19:19:24

darkfeline
Member
Registered: 2012-02-14
Posts: 94

Default ZSH configuration is overriding PATH environment variable

After debugging why PATH is not getting set properly in zsh, I figured out that the default Arch configuration is overriding PATH.

The load order for zsh config files is:

(Taken from http://shreevatsa.wordpress.com/2008/03 … shrc-etc/)

+----------------+-----------+-----------+------+
|                |Interactive|Interactive|Script|
|                |login      |non-login  |      |
+----------------+-----------+-----------+------+
|/etc/zshenv     |    A      |    A      |  A   |
+----------------+-----------+-----------+------+
|~/.zshenv       |    B      |    B      |  B   |
+----------------+-----------+-----------+------+
|/etc/zprofile   |    C      |           |      |
+----------------+-----------+-----------+------+
|~/.zprofile     |    D      |           |      |
+----------------+-----------+-----------+------+
|/etc/zshrc      |    E      |    C      |      |
+----------------+-----------+-----------+------+
|~/.zshrc        |    F      |    D      |      |
+----------------+-----------+-----------+------+
|/etc/zlogin     |    G      |           |      |
+----------------+-----------+-----------+------+
|~/.zlogin       |    H      |           |      |
+----------------+-----------+-----------+------+
|                |           |           |      |
+----------------+-----------+-----------+------+
|                |           |           |      |
+----------------+-----------+-----------+------+
|~/.zlogout      |    I      |           |      |
+----------------+-----------+-----------+------+
|/etc/zlogout    |    J      |           |      |
+----------------+-----------+-----------+------+

Note that on Arch, it's /etc/zsh instead of /etc.

By convention, environment variables are set in .zshenv.  However, /etc/zsh/zprofile, which is loaded after .zshenv, completely nukes PATH, so no matter what I set in .zshenv for PATH, it'll get wiped by /etc/zsh/zprofile.

Does any zsh user have a workaround for this problem?

EDIT: That's not the question I wanted to ask.  I guess I can always source .zshenv in .zprofile, but that's so ugly... Do any other zsh users feel that this should be fixed in Arch's distribution of zsh?

Last edited by darkfeline (2014-04-29 19:21:28)

Offline

#2 2014-04-29 19:57:45

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Default ZSH configuration is overriding PATH environment variable

This has been opened and closed several times on the bugtracker: it's worth reading the various conversations there to get the context and what people do, including me, to work around or within this setup.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2014-04-29 20:47:39

darkfeline
Member
Registered: 2012-02-14
Posts: 94

Re: Default ZSH configuration is overriding PATH environment variable

jasonwryan wrote:

This has been opened and closed several times on the bugtracker: it's worth reading the various conversations there to get the context and what people do, including me, to work around or within this setup.

Somehow I missed that during my initial skim though the bugtracker, but I found it now.

https://bugs.archlinux.org/task/35966
https://bugs.gentoo.org/show_bug.cgi?id=19924 (Gentoo had an interesting one too).

I understand now the problem is that (ba)sh doesn't have as fine-grained control over startup files as zsh.  There also seems to be personal disagreement about where PATH should be set.  Thus, setting path gets shoehorned into profile, and when that gets moved over to zprofile, things get ugly.

Offline

Board footer

Powered by FluxBB