You are not logged in.

#1 2019-08-05 09:15:36

elbowz
Member
Registered: 2014-03-12
Posts: 20

[SOLVED] Zsh don't source /etc/profile.d/*

I have checked inside "/etc/zsh/zprofile":

emulate sh -c 'source /etc/profile'

If I do ". /etc/zsh/zprofile" all works like a charm.

$ echo $SHELL
/bin/zsh

I have try to check the GLOBAL_RCS (echo $GLOBAL_RCS) and is unset, but also if I set it (with "export GLOBAL_RCS=1" in /etc/zsh/zshenv) nothing change.

thanks in advance

Last edited by elbowz (2019-08-06 07:56:23)

Offline

#2 2019-08-05 11:47:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Zsh don't source /etc/profile.d/*

How are you starting zsh?  Those files are/should be only sourced on login shells.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2019-08-05 12:00:13

elbowz
Member
Registered: 2014-03-12
Posts: 20

Re: [SOLVED] Zsh don't source /etc/profile.d/*

I'm starting it in the login shell

edit: if add: "emulate sh -c 'source /etc/profile'" in "~/.zshrc" all works good

for some reason "/etc/zsh/zprofile" is not called (sourced)

Last edited by elbowz (2019-08-05 12:11:31)

Offline

#4 2019-08-05 12:23:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Zsh don't source /etc/profile.d/*

elbowz wrote:

I'm starting it in the login shell

More specifically please.  This could be a misused word here, but starting zsh in a login shell would nout result in /etc/zprofile being source; zsh itself must be started as a login shell.

Have you used chsh to change the default shell to zsh and logged in to a new tty to use zsh?  Or have you passed specific flags to start zsh as a login shell session?  How exactly are you starting zsh?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2019-08-05 12:33:38

elbowz
Member
Registered: 2014-03-12
Posts: 20

Re: [SOLVED] Zsh don't source /etc/profile.d/*

Trilby wrote:
elbowz wrote:

I'm starting it in the login shell

More specifically please.  This could be a misused word here, but starting zsh in a login shell would nout result in /etc/zprofile being source; zsh itself must be started as a login shell.

Have you used chsh to change the default shell to zsh and logged in to a new tty to use zsh?  Or have you passed specific flags to start zsh as a login shell session?  How exactly are you starting zsh?

Sorry for my bad English.

I have put "/bin/zsh" in the last column of my user in the "/etc/password" and restart the pc.

$ cat /etc/passwd | grep mysuer
myuser:x:1000:100::/home/myuser:/bin/zsh

Offline

#6 2019-08-05 13:40:20

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,555

Re: [SOLVED] Zsh don't source /etc/profile.d/*

How do you determine that it's not sourced instead of eg. some desired value being unset/overridden later on?

strace zsh -l 2>&1 | grep profile

?

Offline

#7 2019-08-05 14:08:30

elbowz
Member
Registered: 2014-03-12
Posts: 20

Re: [SOLVED] Zsh don't source /etc/profile.d/*

$ strace zsh -l 2>&1 | grep profile
access("/home/user/.zprofile", F_OK) = -1 ENOENT (No such file or directory)
stat("/etc/zsh/zprofile.zwc", 0x7ffdc5a876f0) = -1 ENOENT (No such file or directory)
stat("/etc/zsh/zprofile", {st_mode=S_IFREG|0644, st_size=36, ...}) = 0
openat(AT_FDCWD, "/etc/zsh/zprofile", O_RDONLY|O_NOCTTY) = 3
access("/etc/profile", F_OK)            = 0
stat("/etc/profile", {st_mode=S_IFREG|0644, st_size=759, ...}) = 0

it seems load correctly the zprofile file... in fact if I execute "zsh -l" in the terminal emulator all works.

I have just discovered the issue appear only in the "graphical terminal emulator" (eg. Konsole on KDE), not on tty (Ctrl+Alt+F2).

edit: maybe this is the reason: https://askubuntu.com/a/503918

Last edited by elbowz (2019-08-05 14:16:09)

Offline

#8 2019-08-05 14:18:21

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Zsh don't source /etc/profile.d/*

This is precisely why I was asking whether this is actually a login shell.  In a terminal emulator you generally are not running a login shell.

I also gather you start X via a display manager, otherwise the desired environment would be inherited from the tty login shell.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#9 2019-08-05 14:19:43

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,555

Re: [SOLVED] Zsh don't source /etc/profile.d/*

Yeah, that's kinda important …

However, this is an xy-problem. Afaiu you're not interested in /etc/zsh/zprofile but in /etc/profile and that should be typically loaded by whatever starts your (GUI) session - and that would be…??

Edit: pecked by a domesticated parrot

Last edited by seth (2019-08-05 14:21:46)

Offline

#10 2019-08-05 14:29:18

elbowz
Member
Registered: 2014-03-12
Posts: 20

Re: [SOLVED] Zsh don't source /etc/profile.d/*

Trilby wrote:

This is precisely why I was asking whether this is actually a login shell.  In a terminal emulator you generally are not running a login shell.

I also gather you start X via a display manager, otherwise the desired environment would be inherited from the tty login shell.

Sorry, I don't know the difference by login, non-login, interactive and non-interactive shell...something to study smile
Yes, Kde should be started by SDDM.

Thanks for the patience!

Offline

#11 2019-08-05 14:35:49

elbowz
Member
Registered: 2014-03-12
Posts: 20

Re: [SOLVED] Zsh don't source /etc/profile.d/*

seth wrote:

Yeah, that's kinda important …

However, this is an xy-problem. Afaiu you're not interested in /etc/zsh/zprofile but in /etc/profile and that should be typically loaded by whatever starts your (GUI) session - and that would be…??

Edit: pecked by a domesticated parrot

Sorry, what you mean?

I have some aliases and environment variables "shared" by the system users, so I guess that the right place was /etc/profile.d/*

eg.
* I want all system users have the alias "alias ll='ls -alF'"
* or something in the PATH variable (eg. ANDROID_SDK)

Offline

#12 2019-08-05 15:24:28

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,555

Re: [SOLVED] Zsh don't source /etc/profile.d/*

The parrot is a reference to Trilby, the other thing is: how do you start … KDE (I guess)? eg. sddm, startx, …

Aliases do typically not belong into the profile, because they relate to interactive  shells. You may want to use /etc/zsh/zshrc

Offline

#13 2019-08-06 07:56:09

elbowz
Member
Registered: 2014-03-12
Posts: 20

Re: [SOLVED] Zsh don't source /etc/profile.d/*

I have moved all stuffs that run at each started shell (eg. terminal emulator aka non-login shell) and is not propagated from sub-shell (eg. alias) in '/etc/zsh/zshrc'.

Now works like a charm.

Thanks to both and to the Archlinux wonderful community!

Offline

#14 2019-08-06 13:49:38

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 714

Re: [SOLVED] Zsh don't source /etc/profile.d/*

Just for reference, SDDM sources /etc/zsh/zprofile (see /usr/share/sddm/scripts/Xsession). So it's strange that it didn't work for you.

Offline

#15 2019-08-06 14:13:54

elbowz
Member
Registered: 2014-03-12
Posts: 20

Re: [SOLVED] Zsh don't source /etc/profile.d/*

nl6720 wrote:

Just for reference, SDDM sources /etc/zsh/zprofile (see /usr/share/sddm/scripts/Xsession). So it's strange that it didn't work for you.

You have right, but aliases set in the /etc/zsh/zprofile will be not present in the terminal emulator.

This, if I have well understood, is because:
* alias is not propagated to sub-shell
* terminal emulator is a non-login shell => not source the /etc/zsh/zprofile

Last edited by elbowz (2019-08-06 14:14:13)

Offline

#16 2019-08-06 15:34:19

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 714

Re: [SOLVED] Zsh don't source /etc/profile.d/*

elbowz wrote:

* alias is not propagated to sub-shell
* terminal emulator is a non-login shell => not source the /etc/zsh/zprofile

Ah, now I get it.

Offline

Board footer

Powered by FluxBB