Opened 18 months ago
Closed 18 months ago
#18130 closed bug (fixed)
XDG_* variables: getenv() gets different results if app is run from a console or from GUI
Reported by: | bipolar | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta4 |
Component: | - General | Version: | R1/beta4 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description (last modified by )
Many ported software makes use of the XDG_* variables ("XDG_CONFIG_HOME", "XDG_DATA_DIRS", etc).
Haiku currently exports those from etc/profile.d/xdg_basedirs.sh
.
The problem is that getenv()
gives different results if the app is launched from a Terminal window, or by double clicking in it, for example. It gets the proper values in the first case, and NULL on the latter.
Will attach a very basic example app (please excuse the poor code) that exhibits this behavior.
Over haikuports this is currently fixed for many apps by directly patching them, but the fix seems to be simpler... as hinted by PulkoMandy here:
just source etc/profile.d/xdg_basedirs.sh
from, for example, ~/config/settings/boot/UserSetupEnvironment
.
To be explicit, adding the following on said file:
source /boot/system/settings/etc/profile.d/xdg_basedirs.sh
After doing that, and a reboot, the attached test case app shows the expected/correct behavior.
Should this be enough/valid for ported apps (instead of individual app patching), or am I missing something else?
Should /system/boot/SetupEnvironment
contain a similar line, or the "exports" should be moved there from the xdg_basedirs.sh
file?
Attachments (1)
Change History (7)
comment:1 by , 18 months ago
Description: | modified (diff) |
---|
comment:2 by , 18 months ago
Description: | modified (diff) |
---|
comment:3 by , 18 months ago
Description: | modified (diff) |
---|
by , 18 months ago
Attachment: | test_getenv_xdgvars.cpp added |
---|
comment:4 by , 18 months ago
comment:5 by , 18 months ago
Description: | modified (diff) |
---|
comment:6 by , 18 months ago
Milestone: | Unscheduled → R1/beta4 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Fix merged in hrev56635 +beta4.
FWIW, I've tested moving the contents of
/system/settings/etc/profile.d/xdg_basedirs.sh
into~/config/settings/boot/UserSetupEnvironment
, and removing the originalxdg_basedirs.sh
file.After a reboot, the test application shows the same (correct) behavior no matter if executed via double click from Tracker, or from a bash session (XDG_* variables available in both cases).
Seems like moving those "externs" to
/system/boot/SetupEnvironment
is the way to go.Proposed change: https://review.haiku-os.org/c/haiku/+/5897