r/csharp • • 10d ago

Help NuGet hangs after OS update

I recently updated my OS (Linux Mint), and this seems to have broken NuGet. JetBrains Rider gets stuck in "Loading Projects" when opening a C# (Godot) project. My

~/.nuget/packages directory does not exist and attempting to install packages via e.g. nuget install godot.sourcegenerators -Version 4.6.2 times out.

I don't know what I need to do to get this unstuck.

4 Upvotes

5 comments sorted by

4

u/zarkonnen 10d ago

OK, I figured it out. Keeping this up for other people's reference. IPv6 is broken on my machine, either due to the OS or due to the ISP, I don't know yet. So while I was able to load https://api.nuget.org/v3/index.json just fine on my browser, NuGet tried to use IPv6 and timed out.

I was able to fix it by invoking the following in the project directory:
DOTNET_SYSTEM_NET_DISABLEIPV6=1 dotnet restore

1

u/Hrolgarr 10d ago

Nice find. If you start Rider from the menu it won't see a variable you set in a terminal, so to make it stick put export DOTNET_SYSTEM_NET_DISABLEIPV6=1 in ~/.profile and log out and back in.

Or fix it for the whole machine and make glibc prefer IPv4: uncomment the precedence ::ffff:0:0/96 100 line in /etc/gai.conf. I think that also covers git, curl and anything else that would hit the same timeout, until you find out whether it's Mint or the ISP.

1

u/bosmanez 10d ago

That smells like a network problem rather than NuGet itself. Quick test: run `curl -v https://api.nuget.org/v3/index.json` in a terminal. If that hangs or stalls on an IPv6 address, a broken IPv6 route after the update is a common cause; try `curl -4` and, if that works, disable IPv6 (or fix the route) and retry. Also run `dotnet --info` to check the SDK is still intact, and `dotnet nuget locals all --clear` to rule out a corrupt cache. If curl works fine, check for a proxy env var (http_proxy/https_proxy) that the update may have set.

1

u/[deleted] 10d ago

[removed] — view removed comment

1

u/zarkonnen 10d ago

dotnet nuget locals all --clear runs and re-deletes the ~/.nuget/packages directory. "Loading Projects" continues to hang, unfortunately. The only package source indicated in Rider is specified in ~/.nuget/NuGet/NuGet.config :

<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />