Skip to content

fix(desktop): let the --debug flag reach MarkText in packaged builds - #5643

Merged
Jocs merged 1 commit into
marktext:developfrom
xThreeh:fix/cli-debug-flag
Oct 8, 2026
Merged

Jocs merged 1 commit into
marktext:developfrom
xThreeh:fix/cli-debug-flag

Conversation

@xThreeh

@xThreeh xThreeh commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5409

Summary

Electron hands its command line to Node, and Node's CLI parser rejects --debug as the removed inspector flag (DEP0062), exiting with code 9 before MarkText reads its arguments. This turns off the nodeCliInspect fuse in electron-builder.yml, so packaged builds skip Node's inspector flags and --debug reaches the app.

Side effect worth knowing: packaged builds no longer honour --inspect / --inspect-brk either (Electron's security checklist recommends this fuse off). MARKTEXT_DEBUG=1 and pnpm run dev are unchanged; dev runs still use the unfused Electron, so issue-5407-debug-mode.spec.ts keeps using MARKTEXT_DEBUG.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • Built electron-builder --linux dir from develop and from this branch and read the renderer's debug flag through --remote-debugging-port:
    • develop: --debug exits with code 9 (DEP0062).
    • this branch: --debug starts with debug=1; no flag and --inspect start with debug=0.
  • Same result on the official 0.20.0 win-x64 build with only this fuse flipped: marktext.exe --debug --help exits 9 (DEP0062) unmodified and prints MarkText's usage with the fuse off.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@Jocs

Jocs commented Oct 7, 2026

Copy link
Copy Markdown
Member

The testing is somewhat redundant. BTW, did you actually package and test it on a real machine?

Electron passes its command line to Node, whose CLI parser treats
`--debug` as the removed inspector flag (DEP0062) and exits with code 9
before MarkText reads its arguments. Turn off the nodeCliInspect fuse in
electron-builder.yml so packaged builds skip Node's inspector flags and
`--debug` reaches the app. Packaged builds also stop honouring
`--inspect`; MARKTEXT_DEBUG and development runs are unchanged.

Fixes #5409
@xThreeh
xThreeh force-pushed the fix/cli-debug-flag branch from e55c117 to 40b247f Compare October 7, 2026 20:59
@xThreeh

xThreeh commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Yes. I tested it on Windows 11 with the official 0.20.0 win-x64 release:

  • Unmodified, marktext.exe --debug --help exits with code 9 and Electron prints [DEP0062]: node --debug and node --debug-brk are invalid.
  • On a copy of the same build where I disabled only EnableNodeCliInspectArguments with @electron/fuses (what this PR makes electron-builder do at packaging time), the same command exits 0 and prints MarkText's usage, and plain marktext.exe --debug starts the app.

Agreed on the test, I dropped electron-fuses.spec.ts; the PR is now only the electron-builder.yml change.

@Jocs
Jocs merged commit 7623c62 into marktext:develop Oct 8, 2026
11 checks passed
@Jocs

Jocs commented Oct 8, 2026

Copy link
Copy Markdown
Member

Thanks.

csells added a commit to csells/MarkText that referenced this pull request Oct 13, 2026
Upstream marktext#5643 ships with EnableNodeCliInspectArguments off so packaged
`--debug` reaches MarkText, and Playwright's Electron launcher, which
attaches through `--inspect`, can no longer start the artifact. Global
setup copies MARKTEXT_PACKAGED_APP's app into test-results, turns only that
fuse on, re-signs the copy ad hoc, checks its app.asar is the artifact's,
and hands the copy to the suite. A new spec launches the artifact itself,
fuse off, over --remote-debugging-port and checks the editor renders with
the expected build commit.
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.

[Bug] The --debug CLI flag never starts the app

2 participants