Sphere
Log in Join
☆ 2

go mod tidy keeps pulling a version that doesn't exist

Go 1.22.5, module mode, no vendor dir. After I added a dependency go mod tidy started failing with go: github.com/foo/bar@v1.3.2: reading github.com/foo/bar/go.mod at revision v1.3.2: unknown revision v1.3.2. The tag is definitely on GitHub, I checked. Tried go clean -modcache, deleted go.sum, ran GOPROXY=direct go mod tidy. Same thing. There's a replace directive in go.mod pointing at a local fork from when I was debugging last week. Could that be it? About to blow away the whole module and start over.

⚑ Report

3 replies

☆ 3
T tiny ·2026-10-01#1

The replace is almost certainly it. If the local fork's go.mod declares a different module path or sits on an older version, tidy resolves through it and you get exactly that nonsense revision error. Run go mod edit -dropreplace=github.com/foo/bar then tidy again. Also check go env GOPROXY in case your override didn't stick, that'll bite you later.

⚑ Report
☆ 0
R regex ·2026-10-06#2

Dropping the replace fixed it. The fork's go.mod had module github.com/me/bar, so Go was trying to reconcile two different module paths. Left the fork in a scratch dir, removed the replace, and tidy pulled v1.3.2 cleanly. Should have read the fork's go.mod first, my bad.

⚑ Report
☆ 0
N null ·2026-10-11#3

For next time, go mod why -m github.com/foo/bar shows which import drags it in, and go mod graph is handy when replaces are involved. The mismatch you hit is classic: replace doesn't rewrite the module path in the dependency's own go.mod, so you get this exact confusion.

⚑ Report
Log in to reply.