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 list misattributed error for missing dependency #70654

Open
nabice opened this issue Dec 3, 2024 · 3 comments
Open

cmd/go: go list misattributed error for missing dependency #70654

nabice opened this issue Dec 3, 2024 · 3 comments
Assignees
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@nabice
Copy link

nabice commented Dec 3, 2024

Go version

go version go1.23.3 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/nabice/.cache/go-build'
GOENV='/home/nabice/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/nabice/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/nabice/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/ssd/source/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/ssd/source/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.3'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/nabice/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/nabice/temp/go_list_bug/go.mod'
GOWORK='/home/nabice/temp/go_list_bug/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2242914037=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Repository: github.com/nabice/golistissue
The project contains seven files, and I've reduced the code as much as possible to reproduce the issue.

git clone https://github.com/nabice/golistissue
go list -e -json=Name,ImportPath,Error,DepOnly,Module -compiled=true -test=false -export=true -deps=true -find=false -pgo=off -- ./...

What did you see happen?

{
        "ImportPath": "github.com/pkg/errors",
        "DepOnly": true,
        "Error": {
                "ImportStack": [
                        "github.com/nabice/golistissue/analytics",
                        "github.com/pkg/errors"
                ],
                "Pos": "util/fileutil.go:4:2",
                "Err": "github.com/nabice/errorpkg@v0.9.1: reading github.com/nabice/errorpkg/go.mod at revision v0.9.1: git ls-remote -q origin in /home/nabice/go/pkg/mod/cache/vcs/878721895ab660b96a101659ca17aa7068c22b888997bc7726d86e2caba4f39f: exit status 128:\n\tfatal: could not read Username for 'https://github.com': terminal prompts disabled\nConfirm the import path was entered correctly.\nIf this is a private repository, see https://golang.org/doc/faq#git_https for additional information."
        }
}

What did you expect to see?

The github.com/pkg/errors package should not contain error information, and the package can be found. I tested it with Go 1.17, and the output was correct.

@mknyszek
Copy link
Contributor

mknyszek commented Dec 3, 2024

CC @golang/tools-team

@mknyszek mknyszek added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Dec 3, 2024
@mknyszek mknyszek added this to the Backlog milestone Dec 3, 2024
@nabice
Copy link
Author

nabice commented Dec 4, 2024

This issue mainly affects go/packages.golistState.shouldAddFilenameFromError in determining whether to extract the filename from the Errors.

@seankhliao seankhliao changed the title cmd/go: Incorrect output from go list cmd/go: go list misattributed error for missing dependency Dec 5, 2024
@matloob matloob self-assigned this Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants