FS#80231 - [rustup][cuda] /etc/profile.d/*.sh adds duplicate entry in PATH

Attached to Project: Arch Linux
Opened by env (ENV25) - Saturday, 11 November 2023, 10:37 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Tuesday, 14 November 2023, 01:13 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Orhun Parmaksız (orhun)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

In a modern system the scripts in `/etc/profile.d/` are run multiple times.
For example, once by the login manager sddm, and again by the virtual terminal konsole.

If `/etc/profile.d/*.sh` scripts use something like `export PATH=$PATH:/usr/lib/rustup/bin` to append to $PATH,
this causes duplicate entries to appear in PATH.

This is why `/etc/profile` has the function `append_path`. The above example should be `append_path "/usr/lib/rustup/bin"`.

Additional info:
* package version(s)
plan9port 20230331-1
rustup 1.26.0-3

plan9port and rustup are the only affected packages I found in my system. If you have access to every package in Arch Linux, the following script should help find affected packages.
```
for file in *.pkg.tar.zst; do bsdtar xvfO "$file" etc/profile.d/ | tr '\0' '\n'; done 2>&1 | grep -v -E '^bsdtar:' | grep -E '^x|\$\{?PATH'
```
This task depends upon

Closed by  Sven-Hendrik Haase (Svenstaro)
Tuesday, 14 November 2023, 01:13 GMT
Reason for closing:  Fixed
Comment by Toolybird (Toolybird) - Saturday, 11 November 2023, 22:28 GMT
> In a modern system the scripts in `/etc/profile.d/` are run multiple times.

Not always. An optimally configured system won't see this issue i.e. one that doesn't unnecessarily spawn login shells.

> For example, once by the login manager sddm, and again by the virtual terminal konsole.

I just tried this right now in a fresh Plasma VM. When opening multiple konsole windows there is *no* duplication (at least with my shell config).

But yeah, using append_path is probably better. There are things like "tmux" that like to spawn a login shell by default. Related  FS#66339 
Comment by Sven-Hendrik Haase (Svenstaro) - Sunday, 12 November 2023, 02:56 GMT
cuda 12.3.0-4 is also affected.
Comment by Sven-Hendrik Haase (Svenstaro) - Sunday, 12 November 2023, 03:00 GMT
rustup should be fixed, please check.
Comment by env (ENV25) - Monday, 13 November 2023, 15:02 GMT
rustup is fixed.
Comment by env (ENV25) - Monday, 13 November 2023, 15:48 GMT
Toolybird, you are correct. I am actually using wezterm, I used konsole as an example. Sorry for the confusion.

It seems wezterm starts a login shell by default for some reason. I am not sure if that is the correct behavior. The following config seems to fix it:
```
config.default_prog = { os.getenv("SHELL") }
```
Comment by Alexander F. Rødseth (xyproto) - Monday, 13 November 2023, 19:32 GMT
I updated the plan9port package.

Loading...