https://bugs.kde.org/show_bug.cgi?id=491579
Bug ID: 491579 Summary: startplasma breaks variable merging between profile.d and environment.d Classification: Plasma Product: plasmashell Version: 6.1.3 Platform: Other OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: Startup process Assignee: plasma-b...@kde.org Reporter: mar...@marcan.st CC: k...@davidedmundson.co.uk Target Milestone: 1.0 SUMMARY If the same variable is appended to (PATH-style) in both /etc/profile.d/ and /usr/lib/environment.d/, startplasma breaks the combination and ends up causing the environment.d value to be lost. This happens because startplasma performs the following sequence of events: 0. (systemd has already loaded /usr/lib/environment.d/* into the user environment at this point, setting TESTVAR=:environment there) 1. startplasma:runEnvironmentScripts(): enumerates files in /etc/xdg/plasma-workspace/env and, 2. Passes them as args to /usr/libexec/plasma-sourceenv.sh to capture their environment, *without* the systemd environment imported as the process environment at this point, which: a) Runs in a shell, sourcing /etc/profile.d/*.sh, setting TESTVAR=:profile b) Prints out all the environment back to the caller 3. Sets its own environment from the output of the above, setting TESTVAR=:profile in the startplasma process 3. syncDBusEnvironment(): Syncs all process env variables back into systemd, *replacing* TESTVAR=:environment with TESTVAR=:profile there 4. importSystemdEnvrionment() (sic): Imports the systemd environment into the process environment, but at this point TESTVAR=:profile there already. The /usr/lib/environment.d setting was lost. 5. Starts the session, with TESTVAR=:profile in the environment STEPS TO REPRODUCE 1. echo 'TESTVAR=$TESTVAR:environment' | sudo tee /usr/lib/environment.d/testvar.conf 2. echo 'export TESTVAR=$TESTVAR:profile' | sudo tee /etc/profile.d/testvar.sh 3. Log out and back in 4. echo $TESTVAR; systemctl --user show-environment | grep TESTVAR OBSERVED RESULT :profile:profile TESTVAR=:profile (The first :profile comes from startplasma sourcing /etc/profile.d, the second one comes from the Konsole shell sourcing it again) EXPECTED RESULT Both lines: something with :profile and :environment each at least once SOFTWARE/OS VERSIONS Operating System: Fedora Linux Asahi Remix 40 KDE Plasma Version: 6.1.3 KDE Frameworks Version: 6.4.0 Qt Version: 6.7.2 ADDITIONAL INFORMATION This can be worked around by creating /etc/xdg/plasma-workspace/env/00capture.sh with the following contents: ``` #!/bin/sh set -a . <(systemctl --user show-environment) source /etc/profile.d/*.sh ``` This forces the systemd user env to be imported into the startup scripts environment context, and then the profile.d scripts to be sourced again, thus combining them as intended and populating them into the startplasma environment (which then syncs the now merged value into systemd, achieving the desired result of having it in both the systemd environment and the actual session process environment). This blocks usage of environment.d for widevine-installer: https://bugzilla.redhat.com/show_bug.cgi?id=2250529 -- You are receiving this mail because: You are watching all bug changes.