Skip to content
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: 'go get' does not add missing hash to go.sum when ziphash file missing from cache [1.16 backport] #44812

Closed
gopherbot opened this issue Mar 5, 2021 · 3 comments
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge release-blocker
Milestone

Comments

@gopherbot
Copy link

@jayconrod requested issue #44749 to be considered for backport to the next 1.16 minor release.

@gopherbot Please backport to 1.16. It's a pre-existing issue, but it's much more likely to be observed because of the switch to -mod=readonly by default.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Mar 5, 2021
@gopherbot gopherbot added this to the Go1.16.1 milestone Mar 5, 2021
@gopherbot
Copy link
Author

Change https://golang.org/cl/298851 mentions this issue: [release-branch.go1.16] cmd/go/internal/modfetch: detect and recover from missing ziphash file

@dmitshur
Copy link
Contributor

Approving per discussion in a release meeting. This backport applies to both 1.16 (this issue) and 1.15 (#44872).

@dmitshur dmitshur added CherryPickApproved Used during the release process for point releases and removed CherryPickCandidate Used during the release process for point releases labels Mar 12, 2021
@gopherbot
Copy link
Author

Closed by merging 33fb479 to release-branch.go1.16.

gopherbot pushed a commit that referenced this issue Mar 25, 2021
…from missing ziphash file

Previously, if an extracted module directory existed in the module
cache, but the corresponding ziphash file did not, if the sum was
missing from go.sum, we would not verify the sum. This caused 'go get'
not to write missing sums. 'go build' in readonly mode (now the
default) checks for missing sums and doesn't attempt to fetch modules
that can't be verified against go.sum.

With this change, when requesting the module directory with
modfetch.DownloadDir, if the ziphash file is missing, the go command
will re-hash the zip without downloading or re-extracting it again.

Note that the go command creates the ziphash file before the module
directory, but another program could remove it separately, and it
might not be present after a crash.

Fixes #44812

Change-Id: I64551e048a3ba17d069de1ec123d5b8b2757543c
Reviewed-on: https://go-review.googlesource.com/c/go/+/298352
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 302a400)
Reviewed-on: https://go-review.googlesource.com/c/go/+/298851
nikhita added a commit to nikhita/publishing-bot that referenced this issue Apr 26, 2021
gomod-zip copied go's zip creation code but they had diverged.
due to this, gomod-zip created different zip files in the cache
compared to what go mod download would create.

From Go 1.15.11 and Go 1.16.3, go automatically derives the ziphash
from the zip file in the cache - golang/go#44812.
This meant that go added incorrect hash values to go.sum because these
were derived from the zip files produced by the diverged gomod-zip code.

So remove go.sum here and regenerate again using go mod download and go mod tidy.
@golang golang locked and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants