Skip to content

fix(i18n): clear all PyInstaller env vars (not only home dir) on relaunch (v1.13.11)#57

Merged
nelsonduarte merged 1 commit into
mainfrom
fix/i18n-clear-all-pyi-env-vars
May 10, 2026
Merged

fix(i18n): clear all PyInstaller env vars (not only home dir) on relaunch (v1.13.11)#57
nelsonduarte merged 1 commit into
mainfrom
fix/i18n-clear-all-pyi-env-vars

Conversation

@nelsonduarte
Copy link
Copy Markdown
Owner

Summary

Shipped a regression in v1.13.10. Changing language on the Store / installer build now pops up:

`_PYI_APPLICATION_HOME_DIR environment variable is not defined!`

Root cause

PR #50 cleared `_PYI_APPLICATION_HOME_DIR` but PyInstaller `--onefile` actually uses three internal env vars to coordinate the two-phase bootloader handoff on Windows:

```
$ strings runw.exe | grep PYI
_PYI_ARCHIVE_FILE
_PYI_APPLICATION_HOME_DIR
_PYI_PARENT_PROCESS_LEVEL
```

The child process inherits `_PYI_PARENT_PROCESS_LEVEL=1` from the parent. The bootloader uses that to decide "I am a phase-2 launch, my files have already been extracted, just read `_PYI_APPLICATION_HOME_DIR` to find them". We had just cleared that path → bootloader aborts.

Fix

Replace the two explicit `env.remove("…")` calls with a pattern sweep that drops every key matching `PYI` or `_MEIPASS`. The relaunched process now truly starts as a fresh phase-1 launch and runs its own extraction, which is what we wanted from #49 / #50 in the first place.

Robust against future PyInstaller versions adding new internal vars: anything they prefix with `PYI` gets swept automatically.

Test

Built locally with the fix and ran two empirical checks:

  1. Normal launch — `dist/PDFApps.exe` starts cleanly, no error dialog.
  2. Relaunch simulation — spawn parent, spawn child via QProcess with sanitised env, kill parent, observe child survives. Child stayed alive after parent's atexit cleanup; no "_PYI_APPLICATION_HOME_DIR not defined" dialog.

Test plan post-merge

  • Re-build via CI, tag `v1.13.11`
  • Test language change 3-4 times on the new MSIX before re-submitting to the Store
  • Re-submit MSIX to Partner Center, cancelling the current v1.13.10 sit-on-the-store moment is unnecessary — this fix can ship as a normal update over v1.13.10

🤖 Generated with Claude Code

…unch

PR #50 cleared _PYI_APPLICATION_HOME_DIR but left
_PYI_PARENT_PROCESS_LEVEL and _PYI_ARCHIVE_FILE inherited. The
child bootloader sees _PYI_PARENT_PROCESS_LEVEL=1 from the parent,
concludes it is a phase-2 (child-phase) launch, then tries to read
_PYI_APPLICATION_HOME_DIR — which we cleared — and aborts with

    _PYI_APPLICATION_HOME_DIR environment variable is not defined!

Switch to a pattern-based clear that removes anything matching _PYI_*
or _MEIPASS*, so the relaunched process truly starts fresh and is
robust against future PyInstaller versions adding new internal vars.

Verified locally with a build + smoke test + relaunch simulation.

Bumps APP_VERSION to 1.13.11.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nelsonduarte nelsonduarte merged commit 9747ee0 into main May 10, 2026
3 checks passed
@nelsonduarte nelsonduarte deleted the fix/i18n-clear-all-pyi-env-vars branch May 10, 2026 22:14
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