fix(env): run the packaged sidecar from the env, not the install directory - #4
Open
CSSFrancis wants to merge 1 commit into
Open
CSSFrancis wants to merge 1 commit into
CSSFrancis wants to merge 1 commit into
Conversation
A working directory is an open handle, and every process the sidecar spawns inherits it. Rooted at <install>/resources/python, that handle is what kept a Windows update from removing the old version — while staying invisible to the installer's app-running check, which can only match on executable path and finds this interpreter in the managed env instead. So the update dead-ended in "cannot be closed. Please close it manually and click Retry", with the holder nowhere in sight and a Retry that re-runs the identical check. Nothing wanted that working directory: the app is installed into the env as a wheel, and what it reads from the bundle it reads by absolute path. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LABjmRsJFyoiVPfU1hveDU
This branch has not been deployed
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.
Root cause of a Windows auto-update dead end reported against SpyDE (directelectron/spyde#147, still reproducing on 0.5.0 → 0.5.1):
The bug
resolvePythonEnvgave the packaged sidecarcwd: bundledProject—<install>/resources/python.A working directory is an open handle on that directory, and every process the sidecar spawns inherits it. So a surviving backend pins the app's install directory open, and Windows will not let the installer remove it.
The part that made this hard to see: the installer's app-running check can only match processes by their executable path, and the interpreter is
<userData>/python-env/Scripts/python.exe— nowhere near the install directory. So the holder was invisible to the very check meant to clear the way. The installer reported the directory clear, the old version could not be removed, and the update dead-ended with nothing obviously running."The uninstall works fine" is the tell: a standalone uninstall happens with no app and no sidecar, so nothing holds the directory.
The fix
Run from
envDir. Nothing wanted the project directory — the app is installed into the env as a wheel, and what it reads from the bundle it reads by absolute path.The comment on
cwdinbackendProcess.tswas also describing only the dev branch (uv runfindingpyproject.toml); it now says what each mode passes.Tests
Two added to
pythonEnv.test.ts, alongside the existingfindUvcoverage:resourcesPath— the contract itself, stated as the thing that must never regressBoth build a packaged layout whose stamp file already matches the lock, so
resolvePythonEnvanswers from disk without shelling out to uv.I checked they actually catch it: reverted to
cwd: bundledProjectand both fail; restored and both pass.Note for consumers
This is the root-cause half. The app-side half only ever helps when an update goes through the in-app "Restart to install" — an installer run by hand, or an orphan left by an earlier crash, is the installer's problem. SpyDE's installer macro is being widened in parallel to sweep
$APPDATA\*\python-env\*(directelectron/spyde#173), which is what reaps those.Reaching a SpyDE user needs a de-shell release plus a lock bump there.