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: confusing error message when go list is missing checksums for patterns outside the main module #59755

Open
biohazduck opened this issue Apr 21, 2023 · 7 comments
Labels
BadErrorMessage Issues related compiler error messages that should be better. FixPending Issues that have a fix which has not yet been reviewed or submitted. GoCommand cmd/go help wanted modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@biohazduck
Copy link

biohazduck commented Apr 21, 2023

What version of Go are you using (go version)?

$ go version
go version go1.19.3 linux/amd64

Does this issue reproduce with the latest release?

Probably?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/pato/local/bin"
GOCACHE="/home/pato/.cache/go-build"
GOENV="/home/pato/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/pato/go/pkg/mod"
GONOPROXY="github.com/StammBio"
GONOSUMDB="github.com/StammBio"
GOOS="linux"
GOPATH="/home/pato/go"
GOPRIVATE="github.com/StammBio"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="/usr/bin/clang"
CXX="/usr/bin/clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3352220154=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Ran go list github.com/... in a repository and got

go: updates to go.mod needed; to update it:
        go mod tidy

Running go mod tidy did not fix it.

Here's a MWE:

package main

import (
	"golang.org/x/exp/slog"
	"periph.io/x/host/v3"
)

func main() {
	slog.Any("", "")
	host.Init()
}

Running go mod init tg gives me the following go.mod and go.sum

module tg

go 1.19

require (
	golang.org/x/exp v0.0.0-20230420155640-133eef4313cb
	periph.io/x/host/v3 v3.8.0
)

require periph.io/x/conn/v3 v3.7.0 // indirect
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb h1:rhjz/8Mbfa8xROFiH+MQphmAmgqRM0bOMnytznhWEXk=
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
periph.io/x/conn/v3 v3.7.0 h1:f1EXLn4pkf7AEWwkol2gilCNZ0ElY+bxS4WE2PQXfrA=
periph.io/x/conn/v3 v3.7.0/go.mod h1:ypY7UVxgDbP9PJGwFSVelRRagxyXYfttVh7hJZUHEhg=
periph.io/x/host/v3 v3.8.0 h1:T5ojZ2wvnZHGPS4h95N2ZpcCyHnsvH3YRZ1UUUiv5CQ=
periph.io/x/host/v3 v3.8.0/go.mod h1:rzOLH+2g9bhc6pWZrkCrmytD4igwQ2vxFw6Wn6ZOlLY=

What did you expect to see?

A list of go modules

What did you see instead?

go: updates to go.mod needed; to update it:
        go mod tidy
@biohazduck
Copy link
Author

biohazduck commented Apr 21, 2023

Fixed a typo: I was running go list github.com/... not go list ./...

@seankhliao
Copy link
Member

$ go mod why -m github.com/jonboulle/clockwork
# github.com/jonboulle/clockwork
tg
periph.io/x/host/v3
periph.io/x/host/v3/beagle/bone
periph.io/x/conn/v3/pin/pinreg
periph.io/x/conn/v3/pin/pinreg.test
periph.io/x/conn/v3/gpio/gpiotest
github.com/jonboulle/clockwork

so there's a module that's pruned out, does go just need a better error message in this case?

cc @bcmills

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go modules labels Apr 21, 2023
@bcmills
Copy link
Contributor

bcmills commented Apr 21, 2023

Sounds like #56222, maybe?
(We can have a look to see if it's related.)

@bcmills
Copy link
Contributor

bcmills commented Apr 21, 2023

Wait, no. go list github.com/... is wrong — don't run that! 🤦‍♂️

@bcmills
Copy link
Contributor

bcmills commented Apr 21, 2023

In particular: go list github.com/... lists every package in every module in the module graph that begins with the prefix github.com/, even the ones that are normally not relevant. However, go.sum lists checksums for only the modules that are relevant to the dependencies of the main module.

If go list ./... or go list all don't work, that's a problem, but go list github.com/... missing checksums is expected.

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Apr 21, 2023
@bcmills
Copy link
Contributor

bcmills commented Apr 21, 2023

So, I agree with @seankhliao that the problem here is the error message.

We shouldn't say updates to go.mod needed, nor suggest go mod tidy, if the packages and/or patterns we're trying to load are outside of the main module.

@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 21, 2023
@bcmills bcmills added this to the Backlog milestone Apr 21, 2023
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 21, 2023
@bcmills bcmills changed the title cmd/go: go list confused during list resolving cmd/go: confusing error message when go list is missing checksums for patterns outside the main module Apr 21, 2023
@bcmills bcmills modified the milestones: Backlog, Go1.21 May 12, 2023
@bcmills bcmills self-assigned this May 12, 2023
@bcmills bcmills modified the milestones: Go1.21, Go1.22 Jun 20, 2023
@gopherbot
Copy link

Change https://go.dev/cl/536175 mentions this issue: cmd/go: do not suggest go mod tidy when there are packages outside the main module

@bcmills bcmills added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label Feb 1, 2024
@bcmills bcmills modified the milestones: Go1.22, Go1.23 Feb 1, 2024
@bcmills bcmills removed their assignment Mar 11, 2024
@matloob matloob added the BadErrorMessage Issues related compiler error messages that should be better. label Apr 29, 2024
@matloob matloob modified the milestones: Go1.23, Go1.24 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BadErrorMessage Issues related compiler error messages that should be better. FixPending Issues that have a fix which has not yet been reviewed or submitted. GoCommand cmd/go help wanted modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants