Fixes #1621: don't force a Chocolatey Python install when Python already exists - #1940
Open
vinayK34 wants to merge 2 commits into
Open
Fixes #1621: don't force a Chocolatey Python install when Python already exists#1940vinayK34 wants to merge 2 commits into
vinayK34 wants to merge 2 commits into
Conversation
…instead of forcing one `choco install httpie` declared a hard `python3` dependency, so Chocolatey installed its own Python even when the user already had one from python.org. That second installer can fail (exit code 1601), which failed the whole httpie install. The install script now discovers an already-available interpreter (`py -3`, `python`, `python3`), verifies it satisfies the minimum version, and only tells the user to install Python when none is usable. pip failures are now surfaced explicitly instead of being silently ignored.
The dependency is what made Chocolatey install its own Python (and fail with exit code 1601) on machines that already had Python installed. The install script now resolves an existing interpreter itself, so the dependency is not only unnecessary but actively harmful.
vinayK34
marked this pull request as ready for review
August 18, 2026 10:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1621
Problem
choco install httpiefails on any Windows machine that already has Python installed from another source:The reporter's workaround was to uninstall their own Python first — clearly not acceptable.
Root cause
docs/packaging/windows-chocolatey/httpie.nuspecdeclared a hard dependency:Chocolatey resolves this by installing its own
python3/python313package, unconditionally — it has no visibility into a python.org install, so a pre-existing Python doesn't satisfy it. The MSI then fails (1601) because a Python is already installed at/near the target, and sincepython3is a dependency, its failure aborts the entirehttpieinstall.The dependency was never actually needed for the install to work:
tools/chocolateyinstall.ps1invokespy -m pip install httpie==..., andpy(the Windows Python launcher) resolves any registered interpreter, not just Chocolatey's. So the dependency's only real effect was to break installs on machines that already had Python.Fix
httpie.nuspec— drop the forcedpython3dependency (with a comment explaining why, so it doesn't get re-added), and document the Python requirement in the package description instead.tools/chocolateyinstall.ps1— detect an existing interpreter and validate it:py -3, thenpython, thenpython3;sys.version_infoand skips any that fails to run or is older than 3.7 (so a broken shim or an old Python onPATHdoesn't win);choco install python3or python.org — instead of an opaque 1601 from a nested installer;$LASTEXITCODEafter pip and throws on failure. Previously a failing pip left the package marked as successfully installed.Verification
Tested with PowerShell 7.4.6, running the script content pulled back from the pushed branch, against stub interpreters covering each path:
python33.13.2 (the reported case)Installing HTTPie with Python 3.13.2 from '/tmp/stub_ok/python3'→ pip invoked, exit 0. No second Python installed.py -3launcher availablepython3→PY_LAUNCHER_PIP: -m pip install httpie==3.2.2 ..., exit 0HTTPie needs Python 3.7 or newer, but no usable Python interpreter was found on PATH...pip failed to install httpie==3.2.2 (exit code 1).— previously silentpythonshim + workingpython3on PATHAlso verified: the script has no PowerShell parse errors (
[Parser]::ParseFile), and the modified.nuspecis valid XML with 0 declared dependencies.Note for maintainers
.github/workflows/release-choco.ymlinstalls from'.;https://community.chocolatey.org/api/v2/'on awindows-2019GHA image that already ships Python, so CI exercised the "dependency happens to resolve" path and never reproduced this. The workflow needs no change; with the dependency gone it now tests the real code path users hit.