zsh-users
 help / color / mirror / code / Atom feed
* zprofile and .profile sourcing
@ 2022-09-08 21:37 Piscium
  2022-09-08 21:42 ` Eric Cook
  2022-09-08 23:14 ` Felipe Contreras
  0 siblings, 2 replies; 8+ messages in thread
From: Piscium @ 2022-09-08 21:37 UTC (permalink / raw)
  To: zsh-users

I have been trying (unsuccessfully) to figure out why ~/.profile is
sourced in some cases and not in others.

I am on Arch Linux, and zsh is my login shell. If I log in to Arch
over lightdm to a Xfce session, then a variable defined in .profile
becomes part of my environment. I think this is because in Arch
/etc/zsh/zprofile has a single statement that calls /etc/profile in sh
compatibility mode:
https://github.com/archlinux/svntogit-packages/blob/packages/zsh/trunk/zprofile

And here is /etc/profile:
https://github.com/archlinux/svntogit-packages/blob/packages/filesystem/trunk/profile

However if within Xfce I log in to a Linux console with Ctrl-Alt-F4;
or if I log in to a headless (no X, no Wayland) Arch VM in VirtualBox;
then a variable defined in .profile does not become part of my
environment. Why?

The Zsh man page says (in different sections):
"Login shells source /etc/profile followed by $HOME/.profile."
"If the shell is a login shell, commands are read from
/etc/zsh/zprofile and then $ZDOTDIR/.zprofile."

~/ zsh --version
zsh 5.9 (x86_64-pc-linux-gnu)

What am I missing?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zprofile and .profile sourcing
  2022-09-08 21:37 zprofile and .profile sourcing Piscium
@ 2022-09-08 21:42 ` Eric Cook
  2022-09-08 21:45   ` Eric Cook
  2022-09-08 23:14 ` Felipe Contreras
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Cook @ 2022-09-08 21:42 UTC (permalink / raw)
  To: zsh-users

On 9/8/22 17:37, Piscium wrote:
> I have been trying (unsuccessfully) to figure out why ~/.profile is
> sourced in some cases and not in others.
>
> I am on Arch Linux, and zsh is my login shell. If I log in to Arch
> over lightdm to a Xfce session, then a variable defined in .profile
> becomes part of my environment. I think this is because in Arch
> /etc/zsh/zprofile has a single statement that calls /etc/profile in sh
> compatibility mode:
> https://github.com/archlinux/svntogit-packages/blob/packages/zsh/trunk/zprofile
>
> And here is /etc/profile:
> https://github.com/archlinux/svntogit-packages/blob/packages/filesystem/trunk/profile
>
> However if within Xfce I log in to a Linux console with Ctrl-Alt-F4;
> or if I log in to a headless (no X, no Wayland) Arch VM in VirtualBox;
> then a variable defined in .profile does not become part of my
> environment. Why?
>
> The Zsh man page says (in different sections):
> "Login shells source /etc/profile followed by $HOME/.profile."
> "If the shell is a login shell, commands are read from
> /etc/zsh/zprofile and then $ZDOTDIR/.zprofile."
>
> ~/ zsh --version
> zsh 5.9 (x86_64-pc-linux-gnu)
>
> What am I missing?
>

One of more possible things around your display manager is happening,

1) not using your login shell to start graphical environment, but does uses a shell that reads .profile
2) it is manually checking for and sourcing it before starting the graphical environment, possibly with or without your login shell
3) something else unrelated to zsh.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zprofile and .profile sourcing
  2022-09-08 21:42 ` Eric Cook
@ 2022-09-08 21:45   ` Eric Cook
  2022-09-08 22:12     ` Piscium
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Cook @ 2022-09-08 21:45 UTC (permalink / raw)
  To: zsh-users

On 9/8/22 17:42, Eric Cook wrote:
>
> One of more possible things around your display manager is happening,
>
> 1) not using your login shell to start graphical environment, but does uses a shell that reads .profile
> 2) it is manually checking for and sourcing it before starting the graphical environment, possibly with or without your login shell
> 3) something else unrelated to zsh.
>

And is seemingly documented on the archlinux wiki: https://wiki.archlinux.org/title/LightDM#X_session_wrapper


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zprofile and .profile sourcing
  2022-09-08 21:45   ` Eric Cook
@ 2022-09-08 22:12     ` Piscium
  2022-09-08 22:30       ` Lawrence Velázquez
  0 siblings, 1 reply; 8+ messages in thread
From: Piscium @ 2022-09-08 22:12 UTC (permalink / raw)
  Cc: zsh-users

On Thu, 8 Sept 2022 at 22:47, Eric Cook <llua@gmx.com> wrote:
>
> On 9/8/22 17:42, Eric Cook wrote:
> >
> > One of more possible things around your display manager is happening,
> >
> > 1) not using your login shell to start graphical environment, but does uses a shell that reads .profile
> > 2) it is manually checking for and sourcing it before starting the graphical environment, possibly with or without your login shell
> > 3) something else unrelated to zsh.
> >
>
> And is seemingly documented on the archlinux wiki: https://wiki.archlinux.org/title/LightDM#X_session_wrapper

Thanks. In /etc/lightdm/Xsession there is:

# Load profile
for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile"
"$HOME/.xprofile"; do
    if [ -f "$file" ]; then
        echo "Loading profile from $file";
        . "$file"
    fi
done

This means "$HOME/.profile" is loaded.

However in /etc/zsh/zprofile there is:
emulate sh -c 'source /etc/profile'

so I would expect /etc/profile to be loaded in all cases, even when
not logging in over lightdm, and "$HOME/.profile" being sourced
because 'emulate sh' which calls zsh in sh compatibility mode?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zprofile and .profile sourcing
  2022-09-08 22:12     ` Piscium
@ 2022-09-08 22:30       ` Lawrence Velázquez
  2022-09-08 22:45         ` Piscium
  0 siblings, 1 reply; 8+ messages in thread
From: Lawrence Velázquez @ 2022-09-08 22:30 UTC (permalink / raw)
  To: Piscium; +Cc: zsh-users

On Thu, Sep 8, 2022, at 6:12 PM, Piscium wrote:
> However in /etc/zsh/zprofile there is:
> emulate sh -c 'source /etc/profile'
>
> so I would expect /etc/profile to be loaded in all cases, even when
> not logging in over lightdm, and "$HOME/.profile" being sourced
> because 'emulate sh' which calls zsh in sh compatibility mode?

"emulate sh -c ..." just runs the given commands in compatibility
mode.  It does not start a new zsh process, so no startup files are
involved.

-- 
vq


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zprofile and .profile sourcing
  2022-09-08 22:30       ` Lawrence Velázquez
@ 2022-09-08 22:45         ` Piscium
  2022-09-13  7:28           ` Piscium
  0 siblings, 1 reply; 8+ messages in thread
From: Piscium @ 2022-09-08 22:45 UTC (permalink / raw)
  Cc: zsh-users

On Thu, 8 Sept 2022 at 23:32, Lawrence Velázquez <larryv@zsh.org> wrote:

> "emulate sh -c ..." just runs the given commands in compatibility
> mode.  It does not start a new zsh process, so no startup files are
> involved.

Thanks. That, together with Eric's answer, solves my question.
Thanks to you both, and to the zsh developers for a great shell.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zprofile and .profile sourcing
  2022-09-08 21:37 zprofile and .profile sourcing Piscium
  2022-09-08 21:42 ` Eric Cook
@ 2022-09-08 23:14 ` Felipe Contreras
  1 sibling, 0 replies; 8+ messages in thread
From: Felipe Contreras @ 2022-09-08 23:14 UTC (permalink / raw)
  To: Piscium; +Cc: zsh-users

On Thu, Sep 8, 2022 at 4:37 PM Piscium <groknok@gmail.com> wrote:
>
> I have been trying (unsuccessfully) to figure out why ~/.profile is
> sourced in some cases and not in others.

> The Zsh man page says (in different sections):
> "Login shells source /etc/profile followed by $HOME/.profile."

That's only in sh or ksh compatibility mode.

> "If the shell is a login shell, commands are read from
> /etc/zsh/zprofile and then $ZDOTDIR/.zprofile."

As Eric Cook already pointed out, the display manager sources
~/.profile for you when you login, but that doesn't happen in the
console, you need to source ~/.profile from ~/.zprofile.

I actually created a video going step by step on how to create a
proper configuration [1], and I also maintain a very simple
configuration that should be generic enough for everyone [2].

Cheers.

[1] https://youtu.be/ESEP7WezCqY
[2] https://github.com/felipec/dot-team

-- 
Felipe Contreras


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zprofile and .profile sourcing
  2022-09-08 22:45         ` Piscium
@ 2022-09-13  7:28           ` Piscium
  0 siblings, 0 replies; 8+ messages in thread
From: Piscium @ 2022-09-13  7:28 UTC (permalink / raw)
  Cc: zsh-users

On Thu, 8 Sept 2022 at 23:45, Piscium <groknok@gmail.com> wrote:

> Thanks. That, together with Eric's answer, solves my question.
> Thanks to you both, and to the zsh developers for a great shell.

The topic of my original email was to ask for help. I got it, that
topic is closed. However I will go now outside topic to describe what
happened next as it could be useful to some people.

The original issue was my wrong understanding about two things, 'zsh
emulate' and lightdm. That was corrected. But then I thought to myself
that I still knew very little about lightdm, and wondered if there
were simpler alternatives that were easier to fully grasp. After
spending quite a few hours looking at all the console display managers
listed in the Arch wiki [1], I felt no enthusiasm for any so decided
to not use a display manager and instead use xinit. I followed the
excellent instructions in the Arch wiki [2]. Now after I enter my user
name and password at the console I am brought into Xfce, and if I log
out from Xfce I come back to the console. I already converted two
desktops and one laptop to this solution. I have been using this for a
few days and all is well. For me one of the advantages of xinit over
the console display managers is that xinit is much easier to grasp and
configure. Moral of the story, I think xinit is underrated, and
display managers are overrated!

[1] https://wiki.archlinux.org/title/Display_manager#Console
[2] https://wiki.archlinux.org/title/Xinit


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-09-13  9:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-08 21:37 zprofile and .profile sourcing Piscium
2022-09-08 21:42 ` Eric Cook
2022-09-08 21:45   ` Eric Cook
2022-09-08 22:12     ` Piscium
2022-09-08 22:30       ` Lawrence Velázquez
2022-09-08 22:45         ` Piscium
2022-09-13  7:28           ` Piscium
2022-09-08 23:14 ` Felipe Contreras

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).