From 6e5e3762489f9bff398e0e8911e175d21eac8e13 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 18 Aug 2026 16:23:40 +0530 Subject: [PATCH 1/2] Fixes #1621: use an existing Python for the Chocolatey install 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. --- .../tools/chocolateyinstall.ps1 | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/docs/packaging/windows-chocolatey/tools/chocolateyinstall.ps1 b/docs/packaging/windows-chocolatey/tools/chocolateyinstall.ps1 index e27045f342..033acf7ef1 100644 --- a/docs/packaging/windows-chocolatey/tools/chocolateyinstall.ps1 +++ b/docs/packaging/windows-chocolatey/tools/chocolateyinstall.ps1 @@ -1,2 +1,65 @@ -$ErrorActionPreference = 'Stop'; -py -m pip install $env:ChocolateyPackageName==$env:ChocolateyPackageVersion --disable-pip-version-check +$ErrorActionPreference = 'Stop' + +# HTTPie is installed into an existing Python installation via pip, so we need +# a Python interpreter — but NOT necessarily a Chocolatey-managed one. Declaring +# a hard `python3` dependency in the .nuspec makes Chocolatey install its own +# Python even when a perfectly good one is already present (e.g. installed from +# python.org), and that second install can fail outright, taking the whole +# `choco install httpie` down with it. See: +# https://github.com/httpie/cli/issues/1621 +# Instead, we detect whatever Python is already available and only ask the user +# to install one when there is genuinely none. + +$MinimumPythonVersion = [version]'3.7' +$VersionProbe = 'import sys; sys.stdout.write(".".join(str(part) for part in sys.version_info[:3]))' + +function Get-UsablePython { + # In order of preference. `py` is the Windows Python launcher: it finds + # interpreters registered by any installer, not just Chocolatey's. + $candidates = @( + @{ Command = 'py' ; Prefix = @('-3') }, + @{ Command = 'python' ; Prefix = @() }, + @{ Command = 'python3' ; Prefix = @() } + ) + + foreach ($candidate in $candidates) { + $resolved = Get-Command $candidate.Command -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1 + if (-not $resolved) { continue } + + $reported = & $resolved.Path @($candidate.Prefix + @('-c', $VersionProbe)) 2>$null + if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($reported)) { continue } + + try { $version = [version]$reported.Trim() } catch { continue } + if ($version -lt $MinimumPythonVersion) { continue } + + return [pscustomobject]@{ + Path = $resolved.Path + Prefix = $candidate.Prefix + Version = $version + } + } + + return $null +} + +$python = Get-UsablePython +if (-not $python) { + throw @" +HTTPie needs Python $MinimumPythonVersion or newer, but no usable Python interpreter was found on PATH. +Install Python, then run ``choco install httpie`` again: + choco install python3 +Or download an installer from https://www.python.org/downloads/windows/ +(make sure "Add Python to PATH" is enabled). +"@ +} + +Write-Host "Installing HTTPie with Python $($python.Version) from '$($python.Path)'." + +& $python.Path @($python.Prefix + @( + '-m', 'pip', 'install', + "$env:ChocolateyPackageName==$env:ChocolateyPackageVersion", + '--disable-pip-version-check' +)) +if ($LASTEXITCODE -ne 0) { + throw "pip failed to install $env:ChocolateyPackageName==$env:ChocolateyPackageVersion (exit code $LASTEXITCODE)." +} From e884af44ab18846e8bc6ffa91b1efe601a7a3b6d Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 18 Aug 2026 16:24:05 +0530 Subject: [PATCH 2/2] Fixes #1621: drop the forced python3 Chocolatey dependency 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. --- docs/packaging/windows-chocolatey/httpie.nuspec | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/packaging/windows-chocolatey/httpie.nuspec b/docs/packaging/windows-chocolatey/httpie.nuspec index 1d8c69790a..bb4d77194b 100644 --- a/docs/packaging/windows-chocolatey/httpie.nuspec +++ b/docs/packaging/windows-chocolatey/httpie.nuspec @@ -25,6 +25,10 @@ Main features: - Expressive and intuitive syntax - Linux, macOS, Windows, and FreeBSD support - All that and more in 2 simple commands: `http` + `https` + +Requires Python 3.7 or newer. Any existing Python installation is used — including +one installed from python.org — so Chocolatey will not install a second copy of Python. +If no Python is found, the installer tells you how to get one (`choco install python3`). HTTPie HTTPie @@ -40,9 +44,13 @@ Main features: https://github.com/httpie/cli https://httpie.io/docs https://github.com/httpie/cli/issues - - - +