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.
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.
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.
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...