From cdeec77609ecb2bdf73f293b643ba78bfac93cfa Mon Sep 17 00:00:00 2001 From: KellyMichels Date: Wed, 22 Jul 2026 14:49:08 -0500 Subject: [PATCH] fix(bash): don't run the Windows venv python.exe on WSL/Linux/macOS zstart's venv detection fell back to .venv/Scripts/python.exe (a Windows binary) whenever it existed. On a Windows-built project accessed from WSL that file sits on the mount and looks executable, so it got picked and failed with 'exec format error' instead of falling through to python3. Guard that branch to Windows-family shells (msys/cygwin), where a .exe can actually run. Verified on WSL: zstart --detached now backgrounds a stdlib app via python3, serves HTTP 200, logs to /tmp/zstart-.log, and zkill terminates it and frees the port. --- bash/zstart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bash/zstart b/bash/zstart index c55ae78..7f893c8 100644 --- a/bash/zstart +++ b/bash/zstart @@ -72,9 +72,12 @@ start_python() { # [ -d "$root" ] || { err "Project root not found: $root"; return 1; } [ -n "$module" ] || { err "Project '$key' (kind=python) needs 'startModule' in zconfig.json (e.g. \"startModule\": \"pyapp.main\")."; return 1; } - # Prefer the project venv (Unix layout; Scripts/ fallback covers Windows-made venvs). + # Prefer the project venv. The Scripts/python.exe branch is a *Windows* venv + # layout — only runnable from a Windows-family shell (Git Bash/MSYS/Cygwin). + # On WSL/Linux/macOS a Windows-built venv may sit on a mounted drive and look + # executable but can't exec, so guard that branch to fall through to python3. if [ -x "$root/.venv/bin/python" ]; then exe="$root/.venv/bin/python" - elif [ -x "$root/.venv/Scripts/python.exe" ]; then exe="$root/.venv/Scripts/python.exe" + elif [ -x "$root/.venv/Scripts/python.exe" ] && [[ "$OSTYPE" == msys* || "$OSTYPE" == cygwin* ]]; then exe="$root/.venv/Scripts/python.exe" elif command -v python3 >/dev/null 2>&1; then exe="python3" else exe="python"; fi