Skip to content

emrg: restart-to-apply — install runtime python + PYTHONPATH in packaged mode; emrg stop --skip-gui (rant 2026-08-21T12:44:34) - #916

Merged
argszero merged 1 commit into
masterfrom
feature/restart-packaged-python
Aug 21, 2026
Merged

emrg: restart-to-apply — install runtime python + PYTHONPATH in packaged mode; emrg stop --skip-gui (rant 2026-08-21T12:44:34)#916
argszero merged 1 commit into
masterfrom
feature/restart-packaged-python

Conversation

@argszero

Copy link
Copy Markdown
Owner

Restart-to-apply: use the install runtime python + PYTHONPATH in packaged mode

Follow-up to #915 (rant 2026-08-21T12:44:34, GUI "Restart to apply" button).

Bug found during review

The restart flow spawned python -m emrg._stop_all --skip-gui using
_findPython(), which in packaged mode resolves to the host's PATH
python3 — that interpreter has no emrg package importable (the packaged
app's emrg lives in ~/.emrg/install/{source,lib}), so the full-chain stop
would fail with No module named emrg and the relaunch would never happen.

Fix

  • emrg/gui/daemon_client.js: _findInstalledPython() resolves the
    install runtime python exactly like the bin/emrgd launcher
    (bin/python on POSIX; bin/python-dist/python*.exe on Windows, with the
    R100 DLL caveat); _installedPythonPath() returns the launcher-equivalent
    PYTHONPATH="$PREFIX/source:$PREFIX/lib".
  • emrg/gui/main.js emrg:restartDaemon: in packaged mode spawn the
    install python with PYTHONPATH injected; source mode keeps the repo
    venv python. windowsHide added for the Windows black-window case.
  • emrg/__main__.py: emrg stop gains --skip-gui_stop_all(skip_gui=...),
    so the GUI could also drive the CLI directly (same semantics as
    python -m emrg._stop_all --skip-gui).

Tests / verification

  • tests/test_main.py: +1 — emrg stop --skip-gui parses skip_gui=True.
  • tests/test_installer_stop.py: delegation test updated for the new
    sys.exit(_stop_all(skip_gui=...)) dispatch + --skip-gui flag.
  • renderer.smoke.test.js: restart test extended — asserts
    _findInstalledPython() / _installedPythonPath() are used and present
    in both main.js and daemon_client.js.
  • Local: Python pytest 994 passed + 1 skipped (995 collected, Agent.md
    synced), GUI npm test 257 (249 pass + 8 skipped), node --check on
    main.js + daemon_client.js OK, emrg stop --help shows --skip-gui,
    import + CLI OK.

…ackaged mode; emrg stop --skip-gui (rant 2026-08-21T12:44:34 follow-up)

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle

Fresh review of the packaged-mode restart fix (rant 2026-08-21T12:44:34 follow-up):

  • Root cause confirmed: _findPython() in packaged mode falls through to PATH python3, which has no emrg importable — python3 -m emrg._stop_all would fail and the relaunch never happen.
  • daemon_client.js: _findInstalledPython() mirrors the bin/emrgd launcher's python resolution (POSIX bin/python; Windows python-dist\python*.exe with R100 DLL caveat); _installedPythonPath() = install/source:install/lib, matching the launcher's PYTHONPATH.
  • main.js: packaged mode spawns install python with PYTHONPATH injected + windowsHide; source mode unchanged (repo venv).
  • emrg/__main__.py: emrg stop --skip-gui_stop_all(skip_gui=...) — CLI parity with the module path.
  • Tests: +1 CLI parse test, installer delegation test updated, GUI source-level test extended (asserts both helpers present + used). Full local suite green: pytest 994 passed + 1 skipped (995 collected, Agent.md synced), GUI 257 (249+8), node --check OK, emrg stop --help shows --skip-gui, import + CLI OK.

1/3.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle

2nd review (head e0350da, CI test + test-windows PASS on run 32453323985):

  • Fresh local verification on this branch: Python pytest 994 passed + 1 skipped (995 collected, matches Agent.md), GUI npm test 257 (249 pass + 8 skipped), node --check on main.js + daemon_client.js OK, import + CLI OK, emrg stop --help exposes --skip-gui.
  • _findInstalledPython() mirrors the bin/emrgd launcher resolution (POSIX bin/python; Windows python-dist\python*.exe with R100 DLL caveat + python.exe fallback); _installedPythonPath() = install/source:install/lib matching the launcher's PYTHONPATH.
  • main.js: packaged mode spawns install python with PYTHONPATH injected + windowsHide on win32; source mode unchanged (repo venv). emrg/__main__.py wires emrg stop --skip-gui_stop_all(skip_gui=...).
  • Tests cover the new paths (CLI parse + installer delegation + GUI source-level). No issues found.

2/3.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle

3rd consecutive review (head e0350da, MERGEABLE/CLEAN, CI test + test-windows PASS):

  • Fresh local verification on this branch: pytest 994 passed + 1 skipped (995 collected, matches Agent.md), emrg stop --help shows --skip-gui, import + CLI OK, GUI npm test 257 (249 pass / 0 fail / 8 skipped).
  • _findInstalledPython() mirrors the bin/emrgd launcher resolution (bin/python on POSIX; python-dist/python*.exe on Windows with the R100 DLL caveat); _installedPythonPath() returns the launcher-equivalent PYTHONPATH (source:lib). restartDaemon uses the install python + PYTHONPATH in packaged mode, repo venv in source mode; windowsHide added.
  • emrg stop --skip-gui → _stop_all(skip_gui=...) keeps the GUI alive to relaunch itself — correct restart-to-apply semantics (rant 12:44:34 follow-up).
  • Tests cover the new flag parsing, the installer-stop delegation, and the packaged-python presence in main.js/daemon_client.js.

3/3.

@argszero
argszero merged commit 2ad350d into master Aug 21, 2026
2 checks passed
argszero added a commit that referenced this pull request Aug 21, 2026
Co-authored-by: EMRG Evolution <emrg@argszero.dev>
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