Skip to content

fix(desktop): disable RunAsNode fuse on Windows and Linux builds - #1801

Merged
chuks-qua merged 1 commit into
mainfrom
fix/packaged-run-as-node
Oct 5, 2026
Merged

chuks-qua merged 1 commit into
mainfrom
fix/packaged-run-as-node

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What

The packaged app on Windows and Linux now ignores ELECTRON_RUN_AS_NODE. Before this change, launching Mcode.exe from a terminal inside VS Code, Mcode, or another Electron app crashed at startup. These terminals export ELECTRON_RUN_AS_NODE=1.

The fix sets Electron's RunAsNode fuse to off on the GUI binary in after-pack.mjs. macOS is unchanged. This is part of #1799, which stays open for macOS.

Why

PR #1798 fixed this crash for bun run prod:desktop. A packaged app has no launcher of ours that could remove the variable, so the fix has to be in the binary. Electron recommends turning this fuse off for shipped apps anyway.

The change is safe on Windows and Linux because nothing runs the GUI binary in Node mode there:

  • The packaged app uses the separate mcode-server binary for Node-mode work. child.ts:71-72 refuses to start without it.
  • That binary is built before the fuse flip, so it keeps Node mode (after-pack.mjs step 1).
  • Package smoke and terminal attestation use mcode-server on these platforms (terminal-release-evidence.mjs:118,127).

macOS keeps the fuse on because unsigned builds use the GUI binary as the PTY host (terminal-release-evidence.mjs:136-138, smoke-test.mjs:79-90). Changing that needs the macOS smoke test reworked, and macOS can't be tested from Windows.

Review Notes

Evidence. I couldn't build a full local package on Windows, because the node-pty rebuild needs Visual Studio Build Tools, which this machine lacks. Instead I tested the fuse itself. I copied the repo's Electron 35.7.5 binary, ran the built app with ELECTRON_RUN_AS_NODE=1 set, and used a temp MCODE_DATA_DIR.

With the fuse enabled (the default, fuse byte 49), the app crashed:

TypeError: Cannot read properties of undefined (reading 'isPackaged')
    at getServerPortBand (apps/desktop/dist/main/main.cjs:36935:28)
EXIT 1

With RunAsNode turned off by flipFuses (fuse byte 48), the same launch started normally:

Mcode v0.13.0 starting
Server started on port 19600
[perf] Window created: 2842.7ms
[perf] Startup complete: 2843.8ms

Known gaps:


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

A packaged Mcode launched from a terminal inside an Electron app
inherits ELECTRON_RUN_AS_NODE=1, runs main as plain Node, and crashes
in getServerPortBand. Disabling the RunAsNode fuse makes the GUI binary
ignore the variable. Node-mode work already uses the renamed
mcode-server copy, which is built before the fuse flip.

macOS keeps the fuse because unsigned builds run the GUI binary as
their PTY host.

Refs #1799
@chuks-qua
chuks-qua merged commit 2262c46 into main Oct 5, 2026
9 checks passed
@chuks-qua
chuks-qua deleted the fix/packaged-run-as-node branch October 5, 2026 14:46
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