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-<key>.log, and zkill terminates it and
frees the port.
This commit is contained in:
KellyMichels 2026-07-22 14:49:08 -05:00
parent 9811cc1eeb
commit cdeec77609

View File

@ -72,9 +72,12 @@ start_python() { # <key> <port>
[ -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