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: list module@version should suggest -m flag #50713

Open
seankhliao opened this issue Jan 20, 2022 · 5 comments
Open

cmd/go: list module@version should suggest -m flag #50713

seankhliao opened this issue Jan 20, 2022 · 5 comments
Labels
GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@seankhliao
Copy link
Member

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

$ go version
go version devel go1.18-bb7fb8a5fa Wed Jan 19 21:46:55 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/arccy/.cache/go-build"
GOENV="/home/arccy/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/arccy/.data/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/arccy/.data/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/arccy/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/arccy/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-bb7fb8a5fa Wed Jan 19 21:46:55 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4196401972=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ go list -f '{{ .Version }}' miniflux.app@686dd92cb9e486c41f407e93d2e10f6b4609f778
package miniflux.app@686dd92cb9e486c41f407e93d2e10f6b4609f778: can only use path@version syntax with 'go get' and 'go install' in module-aware mode

What did you expect to see?

An error message telling me I may have wanted go list -m ...

What did you see instead?

Error message only mentions go get and go install

cc @bcmills @matloob

@seankhliao seankhliao added the GoCommand cmd/go label Jan 20, 2022
@heschi heschi added this to the Go1.19 milestone Jan 20, 2022
@heschi heschi added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 20, 2022
@AGMETEOR
Copy link

AGMETEOR commented Jan 24, 2022

Hello there @bcmills. I would like to work on this.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/381195 mentions this issue: cmd/go: better error message for when line having '@'

@gopherbot gopherbot modified the milestones: Go1.19, Go1.20 Aug 2, 2022
@gopherbot gopherbot modified the milestones: Go1.20, Go1.21 Feb 1, 2023
@gopherbot gopherbot modified the milestones: Go1.21, Go1.22 Aug 8, 2023
@gopherbot gopherbot modified the milestones: Go1.22, Go1.23 Feb 6, 2024
@matloob
Copy link
Contributor

matloob commented Apr 29, 2024

Echoing bcmills' comment on CL 381195, it seems like just adding go list -m will end up in us getting an overly long list in a context where none of the commands might be what users want (especially when we'll also have to add go run pkg@version if we want to cover all the cases).

We should have a discussion here about what we want the error to be before we proceed. @seankhliao What do you think?

@seankhliao
Copy link
Member Author

tbh I'm not sure why this command can't just work

as for the error message, would it be unreasonable to not list commands in the base error, and check for the error type at call sites? from memory go list and go mod why are the common operations that trip people up over requiring -m for modules

@matloob matloob modified the milestones: Go1.23, Backlog Apr 29, 2024
@matloob
Copy link
Contributor

matloob commented May 28, 2024

as for the error message, would it be unreasonable to not list commands in the base error, and check for the error type at call sites? from memory go list and go mod why are the common operations that trip people up over requiring -m for modules

I think this could be done, but it would take some work to figure out how to do the checking in a "clean" way. The error is currently stored on the package and then the build/list commands check the errors on all the packages and exit (in most circumstances, for example if not list -e) if there's an error. We'd have to figure out the right way to check the errors and act on them properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: No status
Development

No branches or pull requests

5 participants