You are not logged in.
Solution: use .zshenv to set ZDOTDIR instead of .zprofile because zsh looks for .zshenv at home
Hello, users of the archwiki ![]()
The problem: The .zshenv file, located in my $ZDOTDIR directory is not being sourced (on login). The environment variables only gets logged if i nest another zsh session within that session.
This problem is very odd considering on my main workstation (with arch as well), the .zshenv gets sourced instantly on login.
I set the .zprofile file to this line :-
.zprofile
export ZDOTDIR="$HOME/.config/zsh"this is the tree for my ZDOTDIR(~/.config/zsh):
~/.config/zsh/
├── plugins.zsh
├── .zcompdump
├── .zshenv
├── .zsh_history
└── .zshrcfiles such as plugin.zsh and .zshrc (or even .zlogout and .zlogin) loads in perfectly on login but .zshenv is the only file in this computer which requires to be nested inside another zsh session to work properly.
I would really appreciate it if anyone could provide a solution to this
Last edited by thetareefarz (2025-02-27 16:30:32)
i like unix
Offline
have you tried the absolute path?
I don't love rosbeef
Offline
.zshenv is always the first thing ever to be sourced - notably ahead of any .zprofile
You've to set the ZDOTDIR earlier, in doubt via pam_env
Offline
have you tried the absolute path?
tried doing this but still no success
i like unix
Offline
.zshenv is always the first thing ever to be sourced - notably ahead of any .zprofile
You've to set the ZDOTDIR earlier, in doubt via pam_env
nope, i dont even know what 'pam_env' means.
I understand that .zshenv gets sourced before .zprofile.
But the thing is, zsh still looks for .zshenv in ZDOTDIR. I use this same method in my main workstation and in that workstation, there isnt a single .zshenv file in my home directory or else where. I recently reinstalled arch in my machine just today and before reinstalling, i used the same dotfiles which ive used with stow for the same configuration as now but now its different.
I would like to clarify that the method which I use is valid and works on different setups as well.
i like unix
Offline
I would like to clarify that the method which I use is valid
No it's not.
https://man.archlinux.org/man/extra/zsh … DOWN_FILES
I understand that .zshenv gets sourced before .zprofile.
Good, then how do you envision to use .zprofile to make /that/ zsh instance read .zshenv (which it already has read) from a different location.
This is nonsense.
The only way you get to use the different ZDOTDIR to apply is because the environment has been set ahead, which is why it works in nested shells.
=> https://wiki.archlinux.org/title/Environment_variables pick one way, you'll not be able to read .zshenv from a ZDOTDIR that you only set in .zprofile.
Offline
I would like to clarify that the method which I use is valid
No it's not.
https://man.archlinux.org/man/extra/zsh … DOWN_FILESI understand that .zshenv gets sourced before .zprofile.
Good, then how do you envision to use .zprofile to make /that/ zsh instance read .zshenv (which it already has read) from a different location.
This is nonsense.The only way you get to use the different ZDOTDIR to apply is because the environment has been set ahead, which is why it works in nested shells.
=> https://wiki.archlinux.org/title/Environment_variables pick one way, you'll not be able to read .zshenv from a ZDOTDIR that you only set in .zprofile.
im sorry for the little inconvenience. Basically, i set up ly by my user on the other computers I use so it read the .zprofile and therefore set the ZDOTDIR on ly so that when i logged in, the .zshenv was sourced bc .zshenv took the new ZDOTDIR.
I really appreciate your help. Thanks a lot. Also again, sorry.
i like unix
Offline