go module_error ai_generated true

go: github.com/foo/[email protected]: reading github.com/foo/bar/go.mod at revision v1.2.3: unknown revision v1.2.3

ID: go/go-mod-tidy-wrong-version

Also available as: JSON · Markdown · 中文
85%Fix Rate
85%Confidence
1Evidence
2024-01-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
go1.21 active
go1.22 active
go1.23 active

Root Cause

The requested module version does not exist in the remote repository, often due to a typo, tag mismatch, or missing tag.

generic

中文

请求的模块版本在远程仓库中不存在,通常是由于拼写错误、标签不匹配或标签缺失。

Official Documentation

https://go.dev/ref/mod#go-mod-tidy

Workarounds

  1. 90% success Verify the tag exists in the remote repository using 'git ls-remote --tags https://github.com/foo/bar' and correct the version in go.mod.
    Verify the tag exists in the remote repository using 'git ls-remote --tags https://github.com/foo/bar' and correct the version in go.mod.
  2. 85% success Use 'go list -m -versions github.com/foo/bar' to list all available versions and choose a valid one.
    Use 'go list -m -versions github.com/foo/bar' to list all available versions and choose a valid one.

中文步骤

  1. Verify the tag exists in the remote repository using 'git ls-remote --tags https://github.com/foo/bar' and correct the version in go.mod.
  2. Use 'go list -m -versions github.com/foo/bar' to list all available versions and choose a valid one.

Dead Ends

Common approaches that don't work:

  1. Running 'go clean -modcache' and retrying. 95% fail

    The cache is not the issue; the version truly doesn't exist in the remote repo.

  2. Adding a replace directive in go.mod pointing to a local path. 60% fail

    This only works if the local path contains the correct code; it doesn't fix the remote version mismatch.