Repository navigation
fix(makefile): quote RUN_PYTHON so make works on paths containing spaces - #610
Conversation
RUN_PYTHON expands to the interpreter path, and that path may contain
spaces. Unquoted, sh word-splits it, so every make target fails on such
a checkout and ensure-venv blames the wrong thing:
/bin/sh: /Volumes/Some Drive/repo/.venv/bin/python: not found
ERROR: OpenMontage requires Python 3.10+.
Current interpreter is unavailable: .../.venv/bin/python
The interpreter is fine. The diagnosis sends people off to reinstall a
Python they do not need, and `make setup`, `make test`, `make preflight`
and the rest are all unusable until they work out that the space is the
problem.
Quote every command-position use. Display-only uses inside echo strings
are left alone.
Tests: a static check that no command-position use is unquoted, and an
end-to-end check that runs `make ensure-venv` from a temporary directory
whose name contains a space. Both fail on the current Makefile and pass
with this change.
qinghuanandejiangshi
left a comment
There was a problem hiding this comment.
Reviewed the focused Makefile change and its regression coverage. I found no blocking issues.
I verified git diff --check, inspected every $(RUN_PYTHON) command-position use, and independently ran the test's static matcher against the proposed Makefile (zero unquoted command-position matches). The quoting is applied consistently to recipe starts, the PIP variable, the || fallback, and the nested command substitution, while display-only uses remain unchanged.
I could not exercise the GNU Make end-to-end test on this Windows host because make is not installed here; the test correctly marks that environment as skipped. The author's macOS end-to-end run covers the shell behavior this patch targets.
calesthio
left a comment
There was a problem hiding this comment.
Thank you for the focused Makefile quoting repair. Reviewed every changed command-position use of RUN_PYTHON, including PIP, the fallback command and nested substitution, against docs/PR_REVIEW_GUIDE.md. A clean integration with current main passed the static regression (1 passed); the GNU Make end-to-end case was correctly skipped because this Windows environment lacks make. The shell quoting is applied consistently without changing the display-only text, and the author's reported native run supplies the platform-specific execution evidence. No blocking issue found in this diff.
Summary
RUN_PYTHONexpands to the interpreter path, and that path may contain spaces.Unquoted, sh word-splits it, so on such a checkout every make target fails and
ensure-venvreports the wrong cause:The interpreter is fine and already the right version. Nothing about the
message points at the space, so the natural response is to go install a Python
that was never the problem.
make setup,make test,make preflight,make demoand the rest are all unusable until you work it out.Spaces in a checkout path are not exotic: an external volume, a synced folder,
or any user directory with a space in the name will do it.
Related issue
Not filed separately; happy to open one if you would prefer that first.
Changes
$(RUN_PYTHON)in the Makefile: thePIPrecipe variable, recipe line starts, uses after||, and the oneinside a
$$(...)command substitution.echostrings are deliberately left unquoted, sincequoting them would just put quote marks in the printed output.
Testing
New
tests/tools/test_makefile_run_python_quoting.py, two tests:$(RUN_PYTHON)is unquoted.whose name contains a space, points
VIRTUAL_ENVat it, and runsmake ensure-venvfor real.Both fail on current
mainand pass with this change. Test 2 reproduces theexact word-split error above.
Full suite on macOS:
965 passed, 11 skipped(963 before this PR, plus the twotests added here).
Checklist
make test).behavior or usage change; the same commands simply work now.)