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: do not report cached libraries as stale in module mode #46911

Closed
bcmills opened this issue Jun 24, 2021 · 1 comment
Closed

cmd/go: do not report cached libraries as stale in module mode #46911

bcmills opened this issue Jun 24, 2021 · 1 comment
Assignees
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jun 24, 2021

In module mode, non-main packages have no install path: built packages are stored only in the build cache. In module mode, go install for a non-main package only ensures that the build cache is up to date; it does not install the library elsewhere.

According to https://tip.golang.org/cmd/go/#hdr-List_packages_or_modules, the Stale field means:

would go install do anything for this package?

According to that interpretation, we should not report a library as Stale in module mode if it is already up to date in the build cache. Today, we always report libraries as stale:

$ go version
go version devel go1.17-a9bb38222 Thu Jun 24 03:45:33 2021 +0000 linux/amd64

$ go mod init example.com/m
go: creating new go.mod: module example.com/m

$ go get -d golang.org/x/tools/imports
go: downloading golang.org/x/tools v0.1.4
go: downloading golang.org/x/mod v0.4.2
go: downloading golang.org/x/sys v0.0.0-20210510120138-977fb7262007
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go get: added golang.org/x/mod v0.4.2
go get: added golang.org/x/sys v0.0.0-20210510120138-977fb7262007
go get: added golang.org/x/tools v0.1.4
go get: added golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1

$ go list -f '{{if .Stale}}{{.StaleReason}}{{end}}' golang.org/x/tools/imports
stale dependency: golang.org/x/tools/internal/event/label

$ go install golang.org/x/tools/imports

$ go list -f '{{if .Stale}}{{.StaleReason}}{{end}}' golang.org/x/tools/imports
not installed but available in build cache

$ go install golang.org/x/tools/imports

$ go list -f '{{if .Stale}}{{.StaleReason}}{{end}}' golang.org/x/tools/imports
not installed but available in build cache

This came to my attention via https://stackoverflow.com/q/64462190.

CC @jayconrod @matloob

@bcmills bcmills added modules NeedsFix The path to resolution is known, but the work has not been done. labels Jun 24, 2021
@bcmills bcmills self-assigned this Jun 24, 2021
@bcmills bcmills added this to the Go1.18 milestone Jun 24, 2021
@bcmills bcmills modified the milestones: Go1.18, Go1.19 Nov 10, 2021
@bcmills bcmills modified the milestones: Go1.19, Go1.20 Jun 1, 2022
@bcmills
Copy link
Contributor Author

bcmills commented Dec 12, 2022

This appears to have been fixed incidentally by (or in association with) #47257.

$ go version
go version devel go1.20-888047c310 Sun Dec 11 16:34:38 2022 +0000 linux/amd64

$ go mod init example
go: creating new go.mod: module example

$ go get -d golang.org/x/tools/imports
go: downloading golang.org/x/tools v0.4.0
go: downloading golang.org/x/mod v0.7.0
go: downloading golang.org/x/sys v0.3.0
go: added golang.org/x/mod v0.7.0
go: added golang.org/x/sys v0.3.0
go: added golang.org/x/tools v0.4.0

$ go list -f '{{if .Stale}}{{.StaleReason}}{{end}}' golang.org/x/tools/imports
stale dependency: internal/goarch

$ go install golang.org/x/tools/imports

$ go list -f '{{if .Stale}}{{.StaleReason}}{{end}}' golang.org/x/tools/imports

@bcmills bcmills closed this as completed Dec 12, 2022
@golang golang locked and limited conversation to collaborators Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants