fix(installer): cleanup orphan testgen+postgres and log-file encoding on Windows#89
Merged
aarthy-dk merged 2 commits intoMay 15, 2026
Conversation
A previous standalone session that exited dirty (force-killed via Task Manager, browser tab close, etc.) leaves the embedded postgres alive — it was spawned with CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW, so it survives its parent. `tg install` then fails at standalone-setup because the orphan still owns ~/.testgen/pgdata; `tg delete` half-finishes because Windows file-locks the running testgen.exe binary, blocking `uv tool uninstall` from removing it. Add a `stop_standalone_orphans()` helper that: - reads ~/.testgen/pgdata/postmaster.pid → kills that specific PID (so a user's unrelated postgres installs are untouched), - then force-kills testgen.exe by image name (safe — installer is dk-installer.exe; no self-kill risk). Called from `_delete_pip` before `uv tool uninstall`, and from `TestgenStandaloneSetupStep.pre_execute` — which only runs after `_resolve_install_mode` has confirmed no install marker, so the existing "you already have an install, use upgrade or delete" invariant is preserved. Best-effort: silent on a clean machine, never raises (outer try/except guards against transient filesystem/permission glitches). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
On Windows, `logging.FileHandler` opens the log file with `locale.getpreferredencoding()` when no encoding is passed — cp1252 on a US-English install. Lines containing non-ASCII glyphs like ✓ (used in prereq-status output) hit UnicodeEncodeError on emit; the logging module catches it and prints `--- Logging error ---` plus a traceback to stderr. The install still completes, but the noise is alarming. Add `"encoding": "utf-8"` to the file-handler dictConfig so the file is opened in UTF-8 regardless of locale. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
luis-dk
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two Windows-installer robustness fixes surfaced while testing TG-1083.
Jira
TG-1084
Test plan