Skip to content

Commit 23781bb

Browse files
arhxamclaude
andcommitted
fix(server): scrub AppImage XDG_DATA_DIRS and GSETTINGS_SCHEMA_DIR from terminals
The integrated terminal inherits the server process environment. On Linux AppImage builds the runtime's `AppRun` points `XDG_DATA_DIRS` at an `$APPDIR/usr/share` entry and `GSETTINGS_SCHEMA_DIR` at the bundled `$APPDIR/usr/share/glib-2.0/schemas`. The existing scrub (added for #1699) only cleaned `PATH`/`LD_LIBRARY_PATH`, so those two leaked into the PTY and `gsettings` inside the terminal reported "No schemas installed" (and tools saw the AppImage's data dir instead of the host's). Both are colon-separated search paths, so add them to the same `APPIMAGE_PATH_LIKE_ENV_KEYS` scrub: the AppImage mount segments are dropped and the user's real entries preserved, and when only mount segments remain the variable is removed so the shell falls back to the platform default. Extended the existing AppImage terminal test to assert both. Closes #5059 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent e259dd2 commit 23781bb

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

‎apps/server/src/terminal/Manager.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,8 @@ it.layer(
13451345
OWD: "/home/user/project",
13461346
PATH: `${appDir}/usr/bin:${appDir}:/usr/local/bin:/usr/bin:/bin`,
13471347
LD_LIBRARY_PATH: `${appDir}/usr/lib:/home/user/.local/lib`,
1348+
XDG_DATA_DIRS: `${appDir}/usr/share:/usr/local/share:/usr/share`,
1349+
GSETTINGS_SCHEMA_DIR: `${appDir}/usr/share/glib-2.0/schemas`,
13481350
TEST_TERMINAL_KEEP: "keep-me",
13491351
},
13501352
});
@@ -1364,6 +1366,11 @@ it.layer(
13641366
// mount segments that the runtime prepended.
13651367
expect(spawnInput.env.PATH).toBe("/usr/local/bin:/usr/bin:/bin");
13661368
expect(spawnInput.env.LD_LIBRARY_PATH).toBe("/home/user/.local/lib");
1369+
// XDG_DATA_DIRS keeps the host entries but drops the AppImage share dir.
1370+
expect(spawnInput.env.XDG_DATA_DIRS).toBe("/usr/local/share:/usr/share");
1371+
// GSETTINGS_SCHEMA_DIR pointed only at the mount, so it is removed and
1372+
// gsettings falls back to the host schema location.
1373+
expect(spawnInput.env.GSETTINGS_SCHEMA_DIR).toBeUndefined();
13671374
// Unrelated host vars still pass through untouched.
13681375
expect(spawnInput.env.TEST_TERMINAL_KEEP).toBe("keep-me");
13691376
}),

‎apps/server/src/terminal/Manager.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,10 +1069,19 @@ function shouldExcludeTerminalEnvKey(key: string): boolean {
10691069
// They describe the AppImage itself, not the user's session, so terminals must
10701070
// not inherit them.
10711071
const APPIMAGE_RUNTIME_ENV_KEYS = ["APPIMAGE", "APPDIR", "ARGV0", "OWD"] as const;
1072-
// PATH-style variables the AppImage runtime prepends with its temporary mount
1073-
// (e.g. /tmp/.mount_T3-XXXX/usr/bin). Only the mount segments are dropped; the
1074-
// user's real entries are preserved.
1075-
const APPIMAGE_PATH_LIKE_ENV_KEYS = ["PATH", "LD_LIBRARY_PATH"] as const;
1072+
// Colon-separated search-path variables the AppImage runtime points at its
1073+
// temporary mount (e.g. /tmp/.mount_T3-XXXX/usr/bin, the bundled glib schemas,
1074+
// and an $APPDIR/usr/share XDG data entry). Only the mount segments are
1075+
// dropped; the user's real entries are preserved. When nothing but mount
1076+
// segments remain the variable is removed entirely so consumers fall back to
1077+
// their platform default (e.g. gsettings finds the host schemas instead of
1078+
// reporting "No schemas installed"). See issues #1699 and #5059.
1079+
const APPIMAGE_PATH_LIKE_ENV_KEYS = [
1080+
"PATH",
1081+
"LD_LIBRARY_PATH",
1082+
"XDG_DATA_DIRS",
1083+
"GSETTINGS_SCHEMA_DIR",
1084+
] as const;
10761085

10771086
function isPathSegmentUnderAppDir(segment: string, appDir: string): boolean {
10781087
return segment === appDir || segment.startsWith(`${appDir}/`);

0 commit comments

Comments
 (0)