Skip to content

[Bug]: Linux -> child processes inherit ELECTRON_RUN_AS_NODE=1 and break other Electron apps #1162

Description

@gustavoilhamorais

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Launch T3 Code
  2. From its environment, run:
    • env | grep ELECTRON_RUN_AS_NODE
    • obsidian help
  3. Observe:
    • ELECTRON_RUN_AS_NODE=1
    • Obsidian fails with Cannot find module 'electron'
  4. Run:
    • env -u ELECTRON_RUN_AS_NODE obsidian help
  5. Observe:
    • Obsidian works normally

Expected behavior

ELECTRON_RUN_AS_NODE=1 should stay scoped to the internal process that needs it and should not be inherited by external commands/apps launched from T3 Code.

Actual behavior

On Linux desktop builds, commands launched from the T3 Code environment can inherit ELECTRON_RUN_AS_NODE=1.

That breaks unrelated Electron apps started from that environment. In my case, obsidian help fails with:

Error: Cannot find module 'electron'

Impact

Major degradation or frequent failure

Version or commit

0.0.11

Environment

linux-lts 6.18.18-1, Hyprland 0.54.2, Node.js 22.22.1, NPM 11.11.1

Logs or stack traces

Screenshots, recordings, or supporting files

No response

Workaround

This does not seem to be a global OS/session issue.

  • Hyprland does not have ELECTRON_RUN_AS_NODE
  • the main t3-code-desktop process does not have it
  • the child process running .../resources/app.asar/apps/server/dist/index.mjs does have it
  • descendants inherit it from there

So the variable appears to leak from the internal server process into child commands.

Activity

  1. added
    bugSomething is broken or behaving incorrectly.
    needs-triageIssue needs maintainer review and initial categorization.
    on Mar 17, 2026
  2. juliusmarminge commented on Jun 20, 2026

    @juliusmarminge
    Member

    The terminal environment sanitizer explicitly blocks ELECTRON_RUN_AS_NODE before spawning child processes, so this is fixed.

    This was closed as part of a large repo-wide maintenance sweep. If you think it's still relevant, please reopen.

  3. rafazaya commented on Aug 29, 2026

    @rafazaya

    This fix is good, but the scope is narrow, and this kind of issue still reproduces on v0.0.36, through a path the terminal fix doesn't cover: agent sessions bypass the sanitizer entirely. Creating a shared helper to be able to cover a broader scope seems like a small fix IMO.

    From a Claude agent session's shell:

    $ env | grep -E '^(APPIMAGE|APPDIR|OWD|LD_LIBRARY_PATH|ELECTRON_RUN_AS_NODE)='
    APPDIR=/tmp/.mount_t3code26Eb74
    OWD=/home/rafa
    LD_LIBRARY_PATH=/tmp/.mount_t3code26Eb74/usr/lib
    APPIMAGE=/home/rafa/.local/bin/t3code.AppImage
    ELECTRON_RUN_AS_NODE=1
    
    $ obsidian
    Error: Cannot find module 'electron'   # same failure as the original report
    

    PATH also still carries the /tmp/.mount_* entries (the #1699 symptom).

    Root cause: the sanitizers from 4b4abcd (TERMINAL_ENV_BLOCKLIST,
    stripAppImageRuntimeEnv) are private to apps/server/src/terminal/Manager.ts
    and only run on the PTY spawn path. Provider sessions build their env in
    apps/server/src/provider/ProviderInstanceEnvironment.ts, where
    mergeProviderInstanceEnvironment defaults baseEnv to process.env and
    returns it unchanged when no custom environment is configured. ClaudeDriver.ts
    (and the other four drivers) pass that straight into the agent spawn, so every
    command an agent runs inherits the Electron/AppImage runtime state.

    Suggested fix: extract the terminal sanitizer into a shared helper and apply
    it in mergeProviderInstanceEnvironment before layering the explicitly
    configured provider variables. One chokepoint covers all five drivers, and the
    desktop→backend spawn (which legitimately needs ELECTRON_RUN_AS_NODE=1) is
    untouched.

    Related: #2867 is the same class of leak on the provider boundary — packaged-backend
    cwd escaping where this is packaged-backend env. A shared "sanitize before provider
    spawn" chokepoint is a natural place to address both.

    Could this be reopened? I'm happy to re-test a build.

  4. xian0x5a commented on Sep 30, 2026

    @xian0x5a

    i can still see the leakage in a Claude session (not the terminal), on 0.0.44 (Linux AppImage).
    Agent cannot run obsidian cli anymore due to the leakage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions