Skip to content

fix(linux): keep AppImage library paths out of extension setup - #444

Merged
lightningpixel merged 1 commit into
devfrom
fix/appimage-child-env
Nov 14, 2026
Merged

lightningpixel merged 1 commit into
devfrom
fix/appimage-child-env

Conversation

@lightningpixel

Copy link
Copy Markdown
Owner

Summary

Fixes point 1 of #236: in-app extension install/Repair fails on the Linux AppImage while the identical setup.py run from a clean shell (env -i) succeeds.

The AppImage launcher points LD_LIBRARY_PATH (and possibly LD_PRELOAD and PATH) into its mount (/tmp/.mount_Modly-XXXX). runExtensionSetup spawned the setup with the raw process.env, so Python, pip and the compilers it runs loaded the AppImage's bundled libraries.

  • New electron/main/child-env.ts, free of Electron imports so it is unit-tested directly:
    • pythonChildEnv(env): the Python/pip redirect stripping cleanPythonEnv() already did (now delegates to it, behaviour unchanged).
    • extensionChildEnv(env): the same, plus removal of every path entry under APPDIR. No-op outside an AppImage, so Windows and macOS are unaffected.
  • Extension setup now runs with extensionChildEnv(process.env).

Deliberately out of scope: the API (and the extension workers it spawns) and process extensions keep their environment. Both relaunch the Electron binary inside the mount (MODLY_NODE_EXECUTABLE, for meshopt), which may need the AppImage's library paths.

The other points of #236 are already addressed on dev: venvs are built from the stable python-embed copy (point 2, since v0.4.3), and POST /extensions/reload stops extension workers (point 4). Point 3 (wheel tag matching) lives in the extensions' own setup.py.

Refs #236

Test plan

  • child-env.test.mjs: mount entries dropped from LD_LIBRARY_PATH / LD_PRELOAD / PATH, empty vars removed, look-alike sibling paths kept, no-op outside an AppImage, input not mutated, pythonChildEnv keeps AppImage paths
  • npm run test:node: 0 failures; ESLint clean; no new tsc errors
  • Needs a Linux AppImage check (maintainers are on Windows): Repair an extension from inside the AppImage and confirm it completes. @OmarB97, since you diagnosed this, would you be able to try a build of this branch?

The AppImage launcher points LD_LIBRARY_PATH (and possibly LD_PRELOAD and
PATH) into its own mount. Extension setup inherited the raw environment, so
Python, pip and the compilers it runs loaded the AppImage's bundled
libraries, and in-app install/Repair failed where the same setup.py
succeeded from a clean shell.

Extension setup now runs with extensionChildEnv(): the Python/pip redirect
stripping cleanPythonEnv() already did, plus removal of any path entry under
APPDIR. It is a no-op outside an AppImage. The API and process extensions
keep their environment, since they relaunch the bundled Electron binary.

Refs #236
@lightningpixel
lightningpixel merged commit 02e976e into dev Nov 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant