-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: removing/switching tags on repository causes a go module checksum mismatch error #33969
Comments
Thank you for reporting this issue @rekby! I am not sure what we can do here since the previous tag no longer exists upstream on the repository, meanwhile your go.mod/go.sum files contain the old checksums, thus you've declared that you want the non-existent commit to be built. This can happen in cases such as if someone However, I shall kindly loop in some go mod experts @bcmills @jayconrod. |
When commit have no tag - go.sum contains part of commit hash - and it allow to computer find commit independent of tags. With commit it is more difficult - rewrite repo history and force push will change commit hashes in git and need full rebuild repo for svn. I suggest add revision/commit hash to in additional to tag names, for example:
it allow human read tag and human/computer read hash. Then if tag point to different commit - go build can error with question what to do (change hash, change tag, stop) or fail with description with variants: change hash for use actual tagged version, change tag - for use previous commit. In any varian commit hash allow manual undestand what was previous state. |
The The overall design of modules is that versions are immutable. A given version of a given module must always refer to the exact same contents. (The checksum database, for which support was added in Go 1.13, helps to ensure that property.) For that reason, we explicitly do not support changing semantic-version tags to point to different contents over time — if you need to tag a new release, it should have a new version number. If you are worried about particular versions of your module dependencies disappearing or being deleted, one mitigation is to use a durable module mirror instead of fetching directly from upstream version control. |
@rekby, did you encounter this problem in the wild, or is this concern mostly theoretical? We've tried to communicate clearly that module versions must be immutable, but perhaps there are some loose ends in the documentation that we can clear up if we can figure out the source of confusion. |
@bcmills it is mote theoretical problem - about repo owner. For example I can change some tags in my small popular (near private) repo some times for ьн сщтмутшутсу if I think about only I use it. Or if I typo in tag (for example set tag v0.2 instead of v0.0.2). If I mistake and somebody add my repo from error tag v0.2 in short time, what tag existed - it can be problem for code consumer. I did not encounded the problem in real wild. |
You may safely change the tags on your repository as long as you are certain that nobody — including If you accidentally typo a tag, such as |
I don't think there's anything more to be done about this. The entire purpose of the |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
go.mod
go.sum
go to repo github.com/rekby-forks/test-mod and remove tag, or remove and put for other commit.
clean go cache
What did you expect to see?
Build same binary, which as on step 4 (need commit exist in github.com/rekby-forks/test-mod)
What did you see instead?
if remove tag:
if switch tag to other commit
The commit exist in repo, it was tag change only. But I can't build binary and can't know what commit I need. Only way - manually (or self script) check every commit.
I think go.sum must contain info about revision of VSC (revision on svn, hash commit for git, hg, etc) and be independent from tags (which can beeasy change/remove).
The text was updated successfully, but these errors were encountered: