You are not logged in.

#1 2022-02-14 19:21:12

UnluckyNinja
Member
Registered: 2022-02-14
Posts: 19

[SOLVED] Problems with .zprofile and .zshenv

I was using Fedora and decided to switch to Arch Linux and I kept most of my dotfiles, but I have been having problems with some environment variables in .zshenv and commands in .zprofile.

Exporting new $PATH locations is working as expected but

export QT_QPA_PLATFORMTHEME="qt5ct"

and

export LD_PRELOAD="/usr/local/lib/libgtk3-nocsd.so.0"

didn't work at all in .zshenv. Even though the variables appear to be set correctly when I echo them. I also use .zprofile to start some systemd user services at login, but these are not working either.

I found this while peeking at journalctl:
pam_env(login:session): deprecated reading of user environment enabled

I don't know if this has anything to do with the .z files problem.

Anyone knows how to fix this?

SOLVED

Solution: Lightdm doesn't source .zprofile and .zshenv by default in Arch. I had to add .zprofile to the files it sources at login at /etc/lightdm/Xsession and I also followed wiki's suggestion for .zshenv

Last edited by UnluckyNinja (2022-02-14 21:06:38)

Offline

#2 2022-02-14 19:30:46

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

Re: [SOLVED] Problems with .zprofile and .zshenv

https://wiki.archlinux.org/title/Zsh#St … down_files

But if you are using OMZ, all bets are off.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2022-02-14 19:38:02

UnluckyNinja
Member
Registered: 2022-02-14
Posts: 19

Re: [SOLVED] Problems with .zprofile and .zshenv

I don't see how this helps me. I know what which file does. My problem is that they appear to not being read properly at user login. It was working in Fedora, but now they are acting weird.

Last edited by UnluckyNinja (2022-02-14 19:38:34)

Offline

#4 2022-02-14 19:47:24

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

Re: [SOLVED] Problems with .zprofile and .zshenv

That section of the wiki describes the order in which they are read. If they "aren't being read properly", it probably means "they aren't being read at all", which suggests there is a prior file that is...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2022-02-14 19:48:10

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Problems with .zprofile and .zshenv

UnluckyNinja wrote:

Exporting new $PATH locations is working as expected but

export QT_QPA_PLATFORMTHEME="qt5ct"

and

export LD_PRELOAD="/usr/local/lib/libgtk3-nocsd.so.0"

didn't work at all in .zshenv. Even though the variables appear to be set correctly when I echo them.

What makes you think that this isn't working if they are echoing the correct value?


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#6 2022-02-14 19:54:27

UnluckyNinja
Member
Registered: 2022-02-14
Posts: 19

Re: [SOLVED] Problems with .zprofile and .zshenv

jasonwryan wrote:

That section of the wiki describes the order in which they are read. If they "aren't being read properly", it probably means "they aren't being read at all", which suggests there is a prior file that is...

But I only have these variables in this file.


Slithery wrote:
UnluckyNinja wrote:

Exporting new $PATH locations is working as expected but

export QT_QPA_PLATFORMTHEME="qt5ct"

and

export LD_PRELOAD="/usr/local/lib/libgtk3-nocsd.so.0"

didn't work at all in .zshenv. Even though the variables appear to be set correctly when I echo them.

What makes you think that this isn't working if they are echoing the correct value?

Because qt5ct keeps saying I need to set up the variable when it appears to be already set. I would believe it was qt5ct bug but it wasn't working for gtk3-nocsd either. Also .zprofile is not starting my user services.

Offline

#7 2022-02-14 19:56:59

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,717

Re: [SOLVED] Problems with .zprofile and .zshenv

And how are you logging in?

Offline

#8 2022-02-14 20:03:45

UnluckyNinja
Member
Registered: 2022-02-14
Posts: 19

Re: [SOLVED] Problems with .zprofile and .zshenv

Scimmia wrote:

And how are you logging in?

I'm using lightdm. This is a ZFS on root install and my home directory is encrypted with ZFS native encryption but I don't think it has anything to do with ZFS. Pam has to load my encryption keys and mount the dataset at first login and I can see that causing problems, but it doesn't unload the key or unmount the dataset at logout and the problem persists at subsequent logins when the home directory is already unencrypted and mounted.


I just added

echo "bla bla bla" > ~/blabla.txt

to my .zprofile and it doesn't create a blabla.txt file at login so it isn't being read.

Offline

#9 2022-02-14 20:07:15

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,717

Re: [SOLVED] Problems with .zprofile and .zshenv

Does it work if you log into an actual terminal and start X from there? DMs don't start normal login shells.

Offline

#10 2022-02-14 20:08:21

tucuxi
Member
From: Switzerland
Registered: 2020-03-08
Posts: 291

Re: [SOLVED] Problems with .zprofile and .zshenv

Thankfully I stopped using lightdm long ago, but I would speculate that it launches a bash session. Try putting the variables in .bash_profile.

Offline

#11 2022-02-14 20:21:37

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Problems with .zprofile and .zshenv

tucuxi wrote:

Thankfully I stopped using lightdm long ago, but I would speculate that it launches a bash session. Try putting the variables in .bash_profile.

You speculate incorrectly. DM's shouldn't launch any login shell...


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#12 2022-02-14 20:29:27

UnluckyNinja
Member
Registered: 2022-02-14
Posts: 19

Re: [SOLVED] Problems with .zprofile and .zshenv

tucuxi wrote:

Thankfully I stopped using lightdm long ago, but I would speculate that it launches a bash session. Try putting the variables in .bash_profile.

It doesn't read .bash_profile either.

Scimmia wrote:

Does it work if you log into an actual terminal and start X from there? DMs don't start normal login shells.

I know lightdm sessions do not read .zlogout when you are logging out, but .zprofile and .zshenv always worked for me. I actually never tried starting x from the command line. I just tried using startx but it outputs errors so I guess I need to do some configuring before I can start x from tty. At least when I log in via tty it creates the blabla.txt file so it is reading .zprofile.

Slithery wrote:
tucuxi wrote:

Thankfully I stopped using lightdm long ago, but I would speculate that it launches a bash session. Try putting the variables in .bash_profile.

You speculate incorrectly. DM's don't usually launch any login shell...

lightdm usually does launch login shells. I have been using lightdm for a while and it does read .zprofile and .zshenv (at least in Fedora it does).

Offline

#13 2022-02-15 10:01:39

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 74,887

Re: [SOLVED] Problems with .zprofile and .zshenv

UnluckyNinja wrote:

lightdm usually does launch login shells

Yes, but no. It does in the sense that it will log into a desktop shell,  but  itwould be stupid to source configurations for specific interactive text shells at this moment.
It's more likely that fedora ships some *profile* in etc or etc/skel that grabs everything it can get hold on or checks your users login shell (if that's zsh) and sources that because reasons - that's not a default nor desired nor sane behavior.
Put the stuff you need globally into global profiles, the stuff you need in X 11 in xprofile and the stuff you need in zsh in zprofile. Don't junk everything into zshenv, that's an awesome way to screw yourself.

Offline

Board footer

Powered by FluxBB