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: missing checksums for dependencies of go get arguments and tests of external dependencies #56222

Closed
matloob opened this issue Oct 13, 2022 · 9 comments
Assignees
Labels
GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@matloob
Copy link
Contributor

matloob commented Oct 13, 2022

cc @bcmills

The following cmd/go script test unexpectedly passes:

cd m2
go mod tidy
cd ../m1
go mod tidy
go get -t example.com/m2/q@v1.0.0 # download everything needed to build test of m2
! go test example.com/m2/q
stderr 'missing go.sum entry for go.mod for module example.com/generics at v1.0.0'

-- m1/go.mod --
module example.com/m1

go 1.20

require example.com/m2 v1.0.0
replace example.com/m2 => ../m2
-- m1/p/p.go --
package p

import _ "example.com/m2/q"
-- m2/go.mod --
module example.com/m2

go 1.20

require example.com/generics v1.0.0
-- m2/q/q.go --
package q
-- m2/q/q_test.go --
package q

import _ "example.com/generics"

What did you expect to see?

The expected behavior is that we have all the sums we need to test a dependency package (example.com/m2/q).

What did you see instead?

There's a sum missing error.

@gopherbot
Copy link

Change https://go.dev/cl/489075 mentions this issue: cmd/go: save checksums for go.mod files needed for go version lines

@bcmills
Copy link
Contributor

bcmills commented May 5, 2023

@gopherbot, please backport to Go 1.19 and 1.20. We should at least report a clear error for missing checksums instead of trying to build with the wrong language version.

@gopherbot
Copy link

Backport issue(s) opened: #60000 (for 1.19), #60001 (for 1.20).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@gopherbot
Copy link

Change https://go.dev/cl/493015 mentions this issue: [release-branch.go1.20] cmd/go: save checksums for go.mod files needed for go version lines

@gopherbot
Copy link

Change https://go.dev/cl/492983 mentions this issue: [release-branch.go1.19] cmd/go: save checksums for go.mod files needed for go version lines

@gopherbot
Copy link

Change https://go.dev/cl/492741 mentions this issue: cmd/go/internal/modload: skip reading go.mod files for imports in 'go mod tidy' of modules before 'go 1.21'

gopherbot pushed a commit that referenced this issue May 10, 2023
… mod tidy' of modules before 'go 1.21'

This eliminate a network access in 'go mod tidy' of an already-tidy
module, which would otherwise be needed to fetch go.mod checksums for
the test dependencies whose go.mod checksums were omitted in Go
releases between Go 1.17 and 1.20 due to bug #56222.

For modules between 'go 1.17' and 'go 1.20' we intentionally preserve
the old 'go mod tidy' output (omitting go.sum entries for the go.mod
files of test dependencies of external packages). We should also avoid
performing extra sumdb lookups for checksums that would be discarded
anyway.

Updates #56222.

Change-Id: I7f0f1c8e902db0e3414c819621c4b99052f503f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/492741
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
@bcmills bcmills changed the title cmd/go: unexpected tidy behavior: missing sum for dependency of test of dependency cmd/go: missing checksums for dependencies of go get arguments and tests of external dependencies May 12, 2023
gopherbot pushed a commit that referenced this issue May 30, 2023
…d for go version lines

When we load a package from a module, we need the go version line from
that module's go.mod file to know what language semantics to use for
the package. We need to save a checksum for the go.mod file even if
the module's requirements are pruned out of the module graph.
Previously, we were missing checksums for test dependencies of
packages in 'all' and packages passed to 'go get -t'.

This change preserves the existing bug for 'go mod tidy',
but fixes it for 'go get -t' and flags the missing checksum
with a clearer error in other cases.

Fixes #60001.
Updates #56222.

Change-Id: Icd6acce348907621ae0b02dbeac04fb180353dcf
(cherry picked from CL 489075 and CL 492741)
Reviewed-on: https://go-review.googlesource.com/c/go/+/493015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue May 30, 2023
…d for go version lines

When we load a package from a module, we need the go version line from
that module's go.mod file to know what language semantics to use for
the package. We need to save a checksum for the go.mod file even if
the module's requirements are pruned out of the module graph.
Previously, we were missing checksums for test dependencies of
packages in 'all' and packages passed to 'go get -t'.

This change preserves the existing bug for 'go mod tidy',
but fixes it for 'go get -t' and flags the missing checksum
with a clearer error in other cases.

Fixes #60000.
Updates #56222.

Change-Id: Icd6acce348907621ae0b02dbeac04fb180353dcf
(cherry picked from CL 489075 and CL 492741)
Reviewed-on: https://go-review.googlesource.com/c/go/+/492983
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
@gopherbot
Copy link

Change https://go.dev/cl/502015 mentions this issue: cmd/go: omit checksums for go.mod files needed for go version lines more often in pre-1.21 modules

@gopherbot
Copy link

Change https://go.dev/cl/502016 mentions this issue: [release-branch.go1.20] cmd/go: omit checksums for go.mod files needed for go version lines more often in pre-1.21 modules

@gopherbot
Copy link

Change https://go.dev/cl/502017 mentions this issue: [release-branch.go1.19] cmd/go: omit checksums for go.mod files needed for go version lines more often in pre-1.21 modules

gopherbot pushed a commit that referenced this issue Jun 12, 2023
…ore often in pre-1.21 modules

This updates the logic from CL 489075 to avoid trying to save extra
sums if they aren't already expected to be present
and cfg.BuildMod != "mod" (as in the case of "go list -m -u all" with
a go.mod file that specifies go < 1.21).

Fixes #60667.
Updates #56222.

Change-Id: Ied6ed3e80a62f9cd9a328b43a415a42d14481056
Reviewed-on: https://go-review.googlesource.com/c/go/+/502015
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopherbot pushed a commit that referenced this issue Jun 13, 2023
…d for go version lines more often in pre-1.21 modules

This updates the logic from CL 489075 to avoid trying to save extra
sums if they aren't already expected to be present
and cfg.BuildMod != "mod" (as in the case of "go list -m -u all" with
a go.mod file that specifies go < 1.21).

Fixes #60698.
Updates #60667.
Updates #56222.

Change-Id: Ied6ed3e80a62f9cd9a328b43a415a42d14481056
Reviewed-on: https://go-review.googlesource.com/c/go/+/502016
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopherbot pushed a commit that referenced this issue Jun 13, 2023
…d for go version lines more often in pre-1.21 modules

This updates the logic from CL 489075 to avoid trying to save extra
sums if they aren't already expected to be present
and cfg.BuildMod != "mod" (as in the case of "go list -m -u all" with
a go.mod file that specifies go < 1.21).

Fixes #60697.
Updates #60667.
Updates #56222.

Change-Id: Ied6ed3e80a62f9cd9a328b43a415a42d14481056
Reviewed-on: https://go-review.googlesource.com/c/go/+/502017
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants