Debian Bug report logs - #968910
sway: Logging in doesn't run ~/.profile

version graph

Package: sway; Maintainer for sway is Sway and related packages team <team+swaywm@tracker.debian.org>; Source for sway is src:sway (PTS, buildd, popcon).

Reported by: Nicholas Eckardt <neckardt@gmail.com>

Date: Sun, 23 Aug 2020 17:39:02 UTC

Severity: normal

Found in version sway/1.5-2

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, neckardt@gmail.com, Sway and related packages team <team+swaywm@tracker.debian.org>:
Bug#968910; Package sway. (Sun, 23 Aug 2020 17:39:04 GMT) (full text, mbox, link).


Acknowledgement sent to Nicholas Eckardt <neckardt@gmail.com>:
New Bug report received and forwarded. Copy sent to neckardt@gmail.com, Sway and related packages team <team+swaywm@tracker.debian.org>. (Sun, 23 Aug 2020 17:39:04 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Nicholas Eckardt <neckardt@gmail.com>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: sway: Logging in doesn't run ~/.profile
Date: Sun, 23 Aug 2020 12:36:47 -0500
Package: sway
Version: 1.5-2+b1
Severity: normal
X-Debbugs-Cc: neckardt@gmail.com

Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?
   	Logging into sway, my changes to $PATH were not run. 
   * What exactly did you do (or not do) that was effective (or
     ineffective)?
     	I set .profile to create a new file when run.
   * What was the outcome of this action? 
  	 This file is created in GNOME, but not created in sway. 
   * What outcome did you expect instead?
   	I expected the file to be created in both GNOME and sway,
	thus indicating that .profile ran. 

*** End of the template - remove these template lines ***


-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 5.7.0-2-amd64 (SMP w/8 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages sway depends on:
ii  libc6                2.31-3
ii  libcairo2            1.16.0-4
ii  libevdev2            1.9.1+dfsg-1
ii  libgdk-pixbuf2.0-0   2.40.0+dfsg-5
ii  libgl1-mesa-dri      20.1.5-1
ii  libgles2             1.3.2-1
ii  libglib2.0-0         2.64.4-1
ii  libinput10           1.16.1-1
ii  libjson-c5           0.15-1
ii  libpango-1.0-0       1.46.0-2
ii  libpangocairo-1.0-0  1.46.0-2
ii  libpcre3             2:8.39-13
ii  libpixman-1-0        0.36.0-1
ii  libsystemd0          246.2-1
ii  libwayland-client0   1.18.0-2~exp1
ii  libwayland-cursor0   1.18.0-2~exp1
ii  libwayland-server0   1.18.0-2~exp1
ii  libwlroots6          0.11.0-2
ii  libxcb1              1.14-2
ii  libxkbcommon0        0.10.0-1
ii  swaybg               1.0-2

Versions of packages sway recommends:
ii  gnome-terminal [x-terminal-emulator]  3.36.2-1
ii  suckless-tools                        45-1
ii  sway-backgrounds                      1.5-2
ii  xterm [x-terminal-emulator]           358-1

Versions of packages sway suggests:
pn  swayidle  <none>
pn  swaylock  <none>

-- no debconf information



Information forwarded to debian-bugs-dist@lists.debian.org, Sway and related packages team <team+swaywm@tracker.debian.org>:
Bug#968910; Package sway. (Sun, 23 Aug 2020 18:30:02 GMT) (full text, mbox, link).


Acknowledgement sent to Birger Schacht <birger@debian.org>:
Extra info received and forwarded to list. Copy sent to Sway and related packages team <team+swaywm@tracker.debian.org>. (Sun, 23 Aug 2020 18:30:02 GMT) (full text, mbox, link).


Message #10 received at 968910@bugs.debian.org (full text, mbox, reply):

From: Birger Schacht <birger@debian.org>
To: Nicholas Eckardt <neckardt@gmail.com>, 968910@bugs.debian.org
Subject: Re: Bug#968910: sway: Logging in doesn't run ~/.profile
Date: Sun, 23 Aug 2020 20:28:17 +0200
Hi,

On 8/23/20 7:36 PM, Nicholas Eckardt wrote:
>    * What led up to the situation?
>    	Logging into sway, my changes to $PATH were not run. 
>    * What exactly did you do (or not do) that was effective (or
>      ineffective)?
>      	I set .profile to create a new file when run.
>    * What was the outcome of this action? 
>   	 This file is created in GNOME, but not created in sway. 
>    * What outcome did you expect instead?
>    	I expected the file to be created in both GNOME and sway,
> 	thus indicating that .profile ran. 


the `.profile` file is the configuration file for the bourne shell. It
is usually not run on login in graphical environments, so GNOME seems to
be special in that way. But you can configure sway to run the file by
adding an exec statement to your swaywm config:
`exec sh ~/.profile` or something similar should work.

For setting environment variables like $PATH there are different
approaches how to set them when starting sway, [0] lists some of them.

[0]
https://www.reddit.com/r/swaywm/comments/gpzqcg/set_environment_variables/

cheers,
Birger



Information forwarded to debian-bugs-dist@lists.debian.org, Sway and related packages team <team+swaywm@tracker.debian.org>:
Bug#968910; Package sway. (Mon, 19 Apr 2021 14:42:03 GMT) (full text, mbox, link).


Acknowledgement sent to Flávio Amieiro <flavioamieiro@gmail.com>:
Extra info received and forwarded to list. Copy sent to Sway and related packages team <team+swaywm@tracker.debian.org>. (Mon, 19 Apr 2021 14:42:03 GMT) (full text, mbox, link).


Message #15 received at 968910@bugs.debian.org (full text, mbox, reply):

From: Flávio Amieiro <flavioamieiro@gmail.com>
To: 968910@bugs.debian.org
Subject: Re: Bug#968910: sway: Logging in doesn't run ~/.profile
Date: Mon, 19 Apr 2021 16:39:51 +0200
[Message part 1 (text/plain, inline)]
Hi,

I'm sorry I couldn't set the "In-Reply-To" header correctly here. I hope
this doesn't mess the thread order.

I just wanted to add some information to this, and maybe we can work around
this issue somehow on debian.

I ran into this issue because I wasn't able to setup my PATH variable on
sway. There, as far as I can tell, two recommended ways of setting up
environment variables: using systemd's ~/.config/environment.d/*.conf
files, and using ~/.pam_environment.

~/.pam_environment was disabled on Debian, to my knowledge, because of
CVE-2010-4708[1], so that is not an option.

Using systemd runs into an issue with how debian's `/etc/profile` overrides
the PATH[2]. A common workaround for this, as I found, is to use ~/.profile
to set PATH, but this didn't seem to work for me. The discussion in this
systemd issue seems to revolve around GNOME, and the solution there was to
use a login shell[3] when running GNOME. That explains why I couldn't use
~/.profile: the default sway.desktop does not use a login shell.

I tried the two suggestions Birger Schacht gave (sorry again about the
messy thread, but I'll quote here).

[...] But you can configure sway to run the file by
> adding an exec statement to your swaywm config:
> `exec sh ~/.profile` or something similar should work.
>
>
Adding this to `.config/sway/config` (if I understood the suggestion
correctly) did not work for me. Even with an `export MY_VAR=1` in my
~/.profile the variable was not in the sway environment. Maybe the `exec`
runs in a subshell or something


> For setting environment variables like $PATH there are different
> approaches how to set them when starting sway, [0] lists some of them.
>
> [0]https://www.reddit.com/r/swaywm/comments/gpzqcg/set_environment_variables/
>
>
The approach suggested here is having a `sway` script somewhere in your
path that overrides the system's sway binary and sets the variable didn't
work for me. I think exactly because at that point PATH is fixed to what is
in Debian's /etc/profile.

The only thing that did work for me was changing the `sway.desktop` file
read by GDM to execute sway inside a login shell. This is similar to the
GNOME solution (even though I'll be the first to admit the solution in [3]
is much better and more complete). The attached patch fixed the issue for
me, as sway is now running under a login shell (so I can use ~/.profile)

This solution works, but I don't want to have this as a permanent solution
for myself since it requires changing a package provided file. Since the
workaround of needing to use ~/.profile is a result of the combination of
two debian specific behaviours, what do you think about having this
solution in the package? I know the patch I provide here is not perfect,
but if you agree I can try to work on a solution similar to GNOME's, which
supports other shells.

Cheers,
Flávio

[1]: https://security-tracker.debian.org/tracker/CVE-2010-4708
[2]: https://github.com/systemd/systemd/issues/6414
[3]:
https://gitlab.gnome.org/GNOME/gnome-session/commit/7e307f8ddb91db5d4051c4c792519a660ba67f35
[Message part 2 (text/html, inline)]
[0001-Uses-login-shell-on-sway.desktop.patch (text/x-patch, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Sway and related packages team <team+swaywm@tracker.debian.org>:
Bug#968910; Package sway. (Thu, 08 Aug 2024 15:48:07 GMT) (full text, mbox, link).


Acknowledgement sent to William R Sowerbutts <will@sowerbutts.com>:
Extra info received and forwarded to list. Copy sent to Sway and related packages team <team+swaywm@tracker.debian.org>. (Thu, 08 Aug 2024 15:48:07 GMT) (full text, mbox, link).


Message #20 received at 968910@bugs.debian.org (full text, mbox, reply):

From: William R Sowerbutts <will@sowerbutts.com>
To: 968910@bugs.debian.org
Subject: Re: Bug#968910: sway: Logging in doesn't run ~/.profile
Date: Thu, 8 Aug 2024 16:25:01 +0100
I wanted to comment that I face exactly the same problem and Flavio's patch 
is the only way I have found to fix this properly ie have one .profile that 
is shared across various login types.

Thanks

Will

On Mon, 19 Apr 2021 16:39:51 +0200 =?UTF-8?Q?Fl=C3=A1vio_Amieiro?= <flavioamieiro@gmail.com> wrote:
> From 9473a37c5b5f44485d07718adbe85ee2c194a1f6 Mon Sep 17 00:00:00 2001
> From: Flavio Amieiro <amieiro.flavio@gmail.com>
> Date: Mon, 19 Apr 2021 16:08:27 +0200
> Subject: [PATCH] Uses login shell on sway.desktop
> 
> ---
>  sway.desktop | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sway.desktop b/sway.desktop
> index 420db5aa..538fbffb 100644
> --- a/sway.desktop
> +++ b/sway.desktop
> @@ -1,5 +1,5 @@
>  [Desktop Entry]
>  Name=Sway
>  Comment=An i3-compatible Wayland compositor
> -Exec=sway
> +Exec=/bin/sh -l -c sway
>  Type=Application
> -- 
> 2.30.2
> 



Information forwarded to debian-bugs-dist@lists.debian.org, Sway and related packages team <team+swaywm@tracker.debian.org>:
Bug#968910; Package sway. (Wed, 18 Sep 2024 11:39:01 GMT) (full text, mbox, link).


Acknowledgement sent to Vladimir K <pzs-fs@yandex.ru>:
Extra info received and forwarded to list. Copy sent to Sway and related packages team <team+swaywm@tracker.debian.org>. (Wed, 18 Sep 2024 11:39:01 GMT) (full text, mbox, link).


Message #25 received at 968910@bugs.debian.org (full text, mbox, reply):

From: Vladimir K <pzs-fs@yandex.ru>
To: 968910@bugs.debian.org
Subject: Re: sway: Logging in doesn't run ~/.profile
Date: Wed, 18 Sep 2024 14:30:01 +0300
This might help: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1074367



Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Thu Nov 21 22:36:34 2024; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.