-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Bug]: Linux AppImage integrated terminal leaks AppImage runtime env into PTY sessions, causing incorrect PHP_BINARY #1699
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
Summary
On Linux AppImage builds, T3 Code's integrated terminal can inherit
AppImage runtime state into PTY sessions.
This creates a mismatch where shell command resolution looks correct, but
process metadata inside launched programs is wrong. In particular, php
resolves from /usr/bin/php, while PHP_BINARY inside the PHP process
reports the AppImage path instead of the real PHP binary.
Environment
- Host OS: Linux
- App packaging: AppImage
- App: T3 Code desktop build
- Shell inside terminal: zsh
Reproduction
Run these inside the T3 integrated terminal:
type php
php -r 'echo PHP_BINARY, PHP_EOL;'
env | grep -E '^(APPIMAGE|APPDIR|OWD|ARGV0|LD_LIBRARY_PATH)='
printf '%s\n' "$PATH"Expected
type phpreports the real PHP binary path, for example/usr/bin/phpphp -r 'echo PHP_BINARY, PHP_EOL;'prints the real PHP binary path- AppImage runtime variables such as
APPIMAGE,APPDIR,OWD, and
ARGV0are not present in the terminal session PATHdoes not contain AppImage mount paths such as
/tmp/.mount_T3-...
Actual
In the broken AppImage build:
type phpreported/usr/bin/phpphp -r 'echo PHP_BINARY, PHP_EOL;'printed
/home/{user}/T3-Code.AppImagePATHcontained AppImage mount paths such as/tmp/.mount_T3-...
Example observed output from the broken build:
php is /usr/bin/php
/home/{user}/T3-Code.AppImage
...
/home/{user}/.bun/bin:...:/usr/bin:/tmp/.mount_T3-Cod...:/tmp/.mount_T3-Cod.../usr/sbin:...
Impact
This creates a subtle but real mismatch between shell resolution and
runtime process metadata inside the integrated terminal.
Root Cause
Source tracing showed:
- the desktop app launches the backend process from Electron main
- the backend inherits the AppImage runtime environment
- the terminal/PTTY layer clones that environment into PTY sessions
- AppImage-specific runtime variables and mount-derived path entries were
not sanitized before spawning the terminal shell
So the terminal was not launching php directly as the AppImage. The
problem was leaked AppImage runtime environment contaminating terminal
child processes.
Relevant Code Paths
apps/desktop/src/main.tsapps/server/src/terminal/Layers/Manager.tsapps/server/src/terminal/Layers/NodePTY.tspackages/shared/src/shell.ts
Proposed Fix
Sanitize AppImage runtime state before PTY shell spawn on Linux:
- remove
APPIMAGE - remove
APPDIR - remove
OWD - remove
ARGV0 - strip AppImage mount entries like
/tmp/.mount_*fromPATH - strip AppImage mount entries like
/tmp/.mount_*from
LD_LIBRARY_PATH
Also apply the same sanitization when hydrating PATH from the login
shell.
Validation After Fix
In the fixed build:
type php->/usr/bin/phpPHP_BINARY-> real PHP binary, for example/usr/bin/php8.5- no
/tmp/.mount_T3-...entries inPATH - no
APPIMAGE,APPDIR,OWD, orARGV0in terminal environment
Notes
- We already have a fix locally and can push code if needed.
Expected behavior
Expected
type phpreports the real PHP binary path, for example/usr/bin/phpphp -r 'echo PHP_BINARY, PHP_EOL;'prints the real PHP binary path- AppImage runtime variables such as
APPIMAGE,APPDIR,OWD, and
ARGV0are not present in the terminal session PATHdoes not contain AppImage mount paths such as
/tmp/.mount_T3-...
Actual behavior
Actual
In the broken AppImage build:
type phpreported/usr/bin/phpphp -r 'echo PHP_BINARY, PHP_EOL;'printed
/home/{user}/T3-Code.AppImagePATHcontained AppImage mount paths such as/tmp/.mount_T3-...
Impact
Major degradation or frequent failure
Version or commit
latest
Environment
Linux
Logs or stack traces
Screenshots, recordings, or supporting files
No response
Workaround
No response