Homebrew/brew.sh

`brew update` failing on ipv6 MacOS Sonoma

Slaviusz opened this issue · 4 comments

Recently I obtained and configured IPv6 prefix on my LAN and it seems MacOS heavily prefers IPv6 in all network communication.

Since then I'm having issues updating brew and downloading formula updates. I have checked and in contrast to Windows and Linux it is (AFAIK) impossible to force IPv4 globally or per session on MacOS.

In default conditions brew update fires and seems to lock up for a long time.

With brew update -v the culprit seems to lie in downloading formula_tap_migrations.jws.json file.

Checking if we need to fetch /opt/homebrew...
Checking if we need to fetch /opt/homebrew/Library/Taps/derailed/homebrew-k9s...
Checking if we need to fetch /opt/homebrew/Library/Taps/hashicorp/homebrew-tap...
Checking if we need to fetch /opt/homebrew/Library/Taps/homebrew/homebrew-cask-versions...
Fetching /opt/homebrew...
Updating /opt/homebrew...
branch 'master' set up to track 'origin/master'.
Switched to and reset branch 'master'
Your branch is up to date with 'origin/master'.
Switched to and reset branch 'stable'
Current branch stable is up to date.
Checking if we need to fetch formula.jws.json...
Updated formula.jws.json.
Checking if we need to fetch cask.jws.json...
Updated cask.jws.json.
Checking if we need to fetch formula_tap_migrations.jws.json...
Checking if we need to fetch cask_tap_migrations.jws.json...
Error: Failed to download https://formulae.brew.sh/api/formula_tap_migrations.jws.json!

When I temporarily disable IPv6 everything runs smoothly. I can provide brew update debug logs if needed.

Thank You for your help.

Unfortunately, GitHub has limited support for IPv6. That URL, along with a number other things Homebrew uses, are backed by GitHub, so we have limited control over what we can do here.

There's an open discussion thread here about GitHub's IPv6 support: https://github.com/orgs/community/discussions/10539

Bo98 commented

Assuming you can connect to IPv4 IPs, my recommendation would be to try set HOMEBREW_CURLRC=1 and add --ipv4 to ~/.curlrc and see if that fixes things or not. I'm not entirely sure where your precise problem lies but for some people that has been the solution. If you want something that's Homebrew specific rather than affecting all curl commands, you can set HOMEBREW_CURLRC to an absolute path pointing to a curlrc-like file.

Some people do have things NAT64 gateways that allows it to work under IPv6 (in particular for networks that cannot connect directly to IPv4 at all), so we're unlikely to pass --ipv4 by default ourselves for that reason as it just shifts who's affected.

Bo98 commented

More generically, you can try curl https://formulae.brew.sh on the command line. If you cannot connect, then you'll need to tweak it until it does work, either by curlrc modifications or changes elsewhere to the system or network. If you cannot get curl to work, then there's very little we can do as many scripts depend on curl.

It should be possible to connect to IPv4 in some fashion, but exactly how depends on your setup a bit.

Hello and thank you. My use case is I had public IPv4 and I got new /64 IPv6 prefix in addition. I already have IPv4 connectivity working but since my LAN devices now also acquire IPv6 addresses MacOS devices started to have issues.

I tested workaround wirh .curlrc and it seems to work. Thank you for your help.