fix: resolve Python interpreter in hook scripts instead of hardcoding python3#670
fix: resolve Python interpreter in hook scripts instead of hardcoding python3#670z3tz3r0 wants to merge 1 commit intoMemPalace:developfrom
Conversation
… python3 Add find_python() to all hook shell scripts — checks MEMPALACE_PYTHON env var first, then falls back to python3, then python. Replaces all hardcoded python3 invocations. This fixes hooks on Windows (where python3 may not exist), pipx/uv-tool installs (where python3 resolves to system Python instead of the install venv), and environments where the interpreter is at a non-standard path. Also add a Python version guard at MCP server startup: if running on Python 3.14+, emit a clear JSON-RPC error instead of crashing with a cryptic pydantic ConfigError from chromadb. Addresses MemPalace#545, MemPalace#650
|
I think the preferred way is to first try mempalace binary if it can be found |
|
Thanks for tackling this — the underlying need is real (we use uv in some setups and don't always have Blocker before we merge: the two Windows checkboxes in the test plan are unchecked, and Windows is the primary platform this fix targets. Specifically the scenarios that would confirm the fix works:
Without those, we'd be merging a Windows fix on faith. Can you run through those three and report back what you saw? Two secondary points to consider while you're in there:
Context on prior art: #740 by @milla-jovovich touched the same files and was closed yesterday. The closure reasoning was narrower than your PR's scope (nohup PATH stripping in a private variant, not addressed by the public cc @milla-jovovich — you closed #740 with a clear model of the hook failure modes; wanted to make sure your perspective is folded in before this lands. |
thanks for the review. |
Summary
python3, which breaks on Windows (python3doesn't exist or resolves to Python 3.14 via Windows Store), pipx/uv-tool installs (python3resolves to system Python instead of the install venv), and non-standard environments.hooks/mempal_save_hook.sh,hooks/mempal_precompact_hook.sh: Addfind_python()that checksMEMPALACE_PYTHONenv var, thenpython3, thenpython. Replace all 5 hardcodedpython3calls with$PYTHON..claude-plugin/hooks/*.sh,.codex-plugin/hooks/*.sh: Samefind_python()added to all 3 plugin hook wrappers.mempalace/mcp_server.py: Add Python 3.14+ version guard — emits a clear JSON-RPC error ("MemPalace requires Python 3.9-3.13") instead of crashing with a cryptic pydanticConfigErrorfrom chromadb.Test plan
pytest tests/ -v— 589 passed, 0 failedgrepconfirms zero barepython3command invocations in hook scriptsMEMPALACE_PYTHON=pythonand verify hooks resolve correctlyAddresses #545, #650