Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Order of zsh config files
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
pillmuncher
n00b
n00b


Joined: 08 Jan 2025
Posts: 2

PostPosted: Wed Jan 08, 2025 6:42 am    Post subject: Order of zsh config files Reply with quote

The official zsh docs say that /etc/zshenv is the first file that's sourced[*] when zsh is started, and in all cases, login/non-login and interactive/non-interactive. But I can't seem to get it to work like that. /etc/zshenv seems to be called, well, never, and /etc/zsh/zprofile only for login shells (which is correct).

I'm used to setting XDG_*_HOME and $ZDOTDIR (to move ~/.zshrc etc. to ~/.config/zsh/) in /etc/zshenv. What am I doing wrong? Or does Gentoo set up zsh differently? How? I cannot find anything in the Wiki.

[*] "Commands are first read from /etc/zshenv; this cannot be overridden" -- https://zsh.sourceforge.io/Doc/Release/Files.html#Startup_002fShutdown-Files
Back to top
View user's profile Send private message
bstaletic
Guru
Guru


Joined: 05 Apr 2014
Posts: 452

PostPosted: Wed Jan 08, 2025 6:54 am    Post subject: Reply with quote

I have not tried, but I think zshenv should be in /etc/zsh/.
I say this, because the default zprofile is in that directory and gentoo ebuild configures zsh with --enable-etcdir="${EPREFIX}"/etc/zsh.
So it looks like wherever docs say /etc, we should be reading that as /etc/zsh.
Back to top
View user's profile Send private message
pillmuncher
n00b
n00b


Joined: 08 Jan 2025
Posts: 2

PostPosted: Wed Jan 08, 2025 8:07 am    Post subject: Reply with quote

Yes, thank you, that was it. Now it works.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22955

PostPosted: Wed Jan 08, 2025 2:55 pm    Post subject: Reply with quote

This thread is useful as a record for anyone else who has the question, but I want to point out that strace could have been used to see what files zsh reads, and in what order. This would not explain why it works the way bstaletic describes, but it would address the immediate question of how to make it work.

The upstream documentation mentioned by OP makes passing mention that /etc may not be right:
https://zsh.sourceforge.io/Doc/Release/Files.html#Startup_002fShutdown-Files wrote:
Files listed above as being in /etc may be in another directory, depending on the installation.
However, it does not inform the user how to determine what that other directory may be. In that regard, bstaletic's explanation seems reasonable to me.
Back to top
View user's profile Send private message
flexibeast
Guru
Guru


Joined: 04 Apr 2022
Posts: 477
Location: Naarm/Melbourne, Australia

PostPosted: Thu Jan 09, 2025 12:27 am    Post subject: Reply with quote

The ebuild for Zsh has a src_configure which contains the line:

Code:
--enable-etcdir="${EPREFIX}"/etc/zsh

without an accompanying patch to the zsh(1) man page to reflect this.

As both a Zsh user and a documentation writer, this presses my buttons, so i've just created an issue on b.g.o about this, offering to provide a patch:

https://bugs.gentoo.org/947747
_________________
https://wiki.gentoo.org/wiki/User:Flexibeast
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum