fix: conda version constraints on Windows - #1146
Conversation
|
Ran a local review, but I'm not on Windows currently, so it's not not able to verify things, so don't trust it too heavily: 🤖 Claude Opus 5 medium effort review from macOS 🤖OverviewThe PR replaces the conda-specific arg-quoting workaround ( Issues1. Arguments containing
Suggested fix in 2.
Smaller points
Things that check out
I could not execute the Windows path here, so the |
|
🤖 AI text below 🤖 Followed up on the earlier macOS review from a Windows 11 machine, so everything below is from actual execution (Python 3.13, The core fix worksReproduced the baseline bug first: unpatched, Issue 1 from the review (embedded quotes) is confirmed, and slightly worse than predicted
The mechanism is as the review guessed: Issue 2 (
|
Quote cmd.exe metacharacters when invoking .bat and .cmd files so conda version constraints reach the launcher unchanged. Re-enable the Windows conda constraint integration coverage. Fixes wntrblm#951
cmd.exe has no backslash escapes - it only counts quote characters - so the backslash-escaped quotes produced by list2cmdline reopen/close the quoting mid-argument and expose the metacharacter: '"urllib3<1.25"' and 'a"<b' fail with "The system cannot find the file specified", and 'a">b' silently succeeds while truncating the argument and redirecting output into a stray file "b" (all verified on Windows 11). Raise a clear ValueError instead, restoring the contract of the removed _dblquote_pkg_install_args, and narrow the docstring: %VAR% expansion cannot be prevented at this layer. Assisted-by: ClaudeCode:claude-fable-5
Deduplicate the echo-arg batch fixture into a helper, parametrize the conda_install kwargs test directly over requirement strings now that no arg rewriting happens, and move _CMD_META next to its only consumer. Assisted-by: ClaudeCode:claude-fable-5
Under MSYS2 the tmp_path-derived Path keeps forward slashes while iterdir() returns backslashes, so equal paths compared unequal. Assisted-by: ClaudeCode:claude-opus-5
8e1ba53 to
7da2b87
Compare
|
And trying a GPT 5.6 Sol review (not from Windows): 🤖 AI text below 🤖 The new Windows batch quoting still permits arguments that cmd.exe expands or interprets and regresses support for previously accepted pre-quoted requirements. Full review comments:
|
|
🤖 AI text below 🤖 Investigated all three findings from the GPT review on a Windows 11 machine (real [P1] Percent expansion — confirmed, worse than stated
Fix: reject an argument only when it references a variable that would actually expand — defined in the child environment (case-insensitive, checked against the Not guarded: delayed expansion ( [P2] Pre-quoted arguments — confirmed regression
[P1] Parentheses — confirmed, and the failure is silentTop-level parens are harmless, but inside an
Quoting fixes both, so CoverageUnit tests for rejection/pass-through/literal-percent behavior, plus Windows integration tests including a conda.bat-style |
|
(I can't copy paste between machines very easily, so I"m using PR comments to communicate between them, sorry!) |
921af06 to
002bcf7
Compare
henryiii
left a comment
There was a problem hiding this comment.
Okay, I'm happy with that. Didn't grow too much (or at all) after a few back-and-forths between GPT and Claude (used /simplify and manually cleaned up too), and removes the workarounds we had (even in our own noxfile).
Thanks!
- reject arguments containing %VAR% references that cmd.exe would expand (verified: expansion happens even inside double quotes and can inject commands from environment values); references to undefined variables are left alone since cmd.exe passes them through literally - quote ( and ) as metacharacters: an unquoted ")" inside a conda.bat style "if (...)" block ends the block early, silently corrupting the argument or aborting the script - accept pre-quoted arguments such as '"urllib3<1.25"' again (the historical workaround from wntrblm#312) instead of raising ValueError Assisted-By: ClaudeCode:claude-fable-5 Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
002bcf7 to
35cf3ab
Compare
Summary
.bator.cmdlaunchersFixes #951.
Validation
python -m pytest tests/test_command.py tests/test_sessions.py -q(203 passed, 6 skipped)prek run ruff-check --files nox/popen.py nox/sessions.py noxfile.py tests/test_command.py tests/test_sessions.pyprek run ruff-format --files nox/popen.py nox/sessions.py noxfile.py tests/test_command.py tests/test_sessions.pyprek run mypy --files nox/popen.py nox/sessions.py noxfile.py