Bug 503467 - /etc/profile runs twice on login
Summary: /etc/profile runs twice on login
Status: CONFIRMED
Alias: None
Product: plasma-mobile
Classification: Plasma
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Mobile Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-28 09:54 UTC by 3n16v85k
Modified: 2025-05-04 15:42 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 3n16v85k 2025-04-28 09:54:06 UTC
SUMMARY

The plasma mobile session runs /etc/profile twice if it is started from SDDM.

STEPS TO REPRODUCE
1. Install SDDM and plasma mobile
2. Add a marker in `/etc/profile`, like `echo "foo" >> /home/<user>/log.txt
3. Log in
4. Open a konsole and run `cat log.txt`

OBSERVED RESULT

The output contains two lines of `foo`

EXPECTED RESULT

Only a single line of `foo`

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Debian 12
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION

This problem causes my `PATH` to be set incorrectly, because the `/etc/profile.d/nix.sh` script only sets the path if it is run for the first time and `/etc/profile` resets the PATH when run a second time.
Comment 1 3n16v85k 2025-04-28 09:58:57 UTC
I've also tried debugging it a bit by adding this line: `echo ${BASH_SOURCE[@]} >> /home/<user>/log.txt` which shows one expected result of `/etc/profile /etc/sddm/wayland-session`, but the second line is blank so I don't know where that second call comes from.
Comment 2 3n16v85k 2025-04-28 11:13:34 UTC
Devin Lin on matrix showed me that `/usr/bin/startplasmamobile` starts by sourcing `/etc/profile`. This is the line:

https://invent.kde.org/plasma/plasma-mobile/-/blob/master/bin/startplasmamobile.in?ref_type=heads#L8

Removing that line fixes the bug.
Comment 3 Devin Lin 2025-05-04 15:42:29 UTC
I'm not really sure whose responsibility it is to source /etc/profile, currently if the session is launched directly through the systemd unit file we provide there would not be a second "source" of /etc/profile...