Homebrew, Curl & HTTP/2 Stream Error
I recently had a problem installing a homebrew package on my MacBook, that was related to the version of CURL on the device.
Problem
Attempting to install the Azure CLI via homebrew using the usual command below resulted in the error below.
brew install azure-cli
curl: (18) HTTP/2 stream 1 was reset Error: azure-cli: Failed to download resource “azure-cli” Download Failed
It seems that the target HTTP server was not handling the HTTP/2 request in the way that Curl was expecting. It turns out that this is not a problem with curl as such but this issue was resolved in a more recent version of than I had installed (or could install) which was version 8.1.2. To find your local curl version run this command:
curl --version
version 8.1.2
Homebrew actually comes with a bundled version of curl, and running this command I could see if was newer than my system default one (but just not being used by homebrew).
brew info curl version 8.2.1
FIX: So resolve the problem I needed to get homebrew to use its own installation of curl instead of the MacBook’s system version by running the below command to set an environment variable…
1
export HOMEBREW_FORCE_BREWED_CURL=1
From that point I was able to run brew install azure-cli successfully.
UPDATE (August-2024):
A colleague had the same problem on his Mac and needed a few more steps to resolve the issue. Making the above change resulted in a new error of
curl(92): HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR
To resolve this error these commands worked:
1
2
3
4
export HOMEBREW_DEVELOPER=1
brew install curl
# change the path below to your curl install path
export HOMEBREW_CURL_PATH=/usr/local/opt/curl/bin/curl>
Then add the HOMEBREW_FORCE_BREWED_CURL environment variable to your environment to force brew to use that curl installation.
1
export HOMEBREW_FORCE_BREWED_CURL=1
Then you should be ok to install Azure CLI.