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 all" fails with "build constraints exclude all Go files in ..." in -mod=vendor mode #41893

Closed
rmadamanchi opened this issue Oct 9, 2020 · 3 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rmadamanchi
Copy link

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

$ go version
go version go1.15.2 linux/amd64

Does this issue reproduce with the latest release?

Same behavior on latest versions of 1.14 and go1.15

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

Linux

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/tmp/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/tmp/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/skaffold/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build621428698=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ git clone https://github.com/GoogleContainerTools/skaffold.git
$ cd skaffold
$ go list all
package golang.org/x/sys/windows: build constraints exclude all Go files in /tmp/skaffold/vendor/golang.org/x/sys/windows

What did you expect to see?

List of packages

What did you see instead?

Below error:

package golang.org/x/sys/windows: build constraints exclude all Go files in /tmp/skaffold/vendor/golang.org/x/sys/windows
@rmadamanchi rmadamanchi changed the title go list all fails with "build constraints exclude all Go files in .." "go list all" fails with "build constraints exclude all Go files in .." Oct 9, 2020
@dmitshur dmitshur changed the title "go list all" fails with "build constraints exclude all Go files in .." cmd/go: "go list all" fails with "build constraints exclude all Go files in ..." Oct 10, 2020
@dmitshur dmitshur added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 10, 2020
@dmitshur dmitshur added this to the Backlog milestone Oct 10, 2020
@dmitshur
Copy link
Contributor

/cc @jayconrod @matloob @bcmills

@dmitshur dmitshur changed the title cmd/go: "go list all" fails with "build constraints exclude all Go files in ..." cmd/go: "go list all" fails with "build constraints exclude all Go files in ..." in -mod=vendor mode Oct 10, 2020
@jayconrod
Copy link
Contributor

Thanks for reporting! I was able to reproduce this in 1.15.2 but not at tip. It looks like @bcmills already fixed this in his rewrite of the module-mode package loading logic for 1.16.

You can work around this in 1.15 using the -e flag.

@dmitshur dmitshur modified the milestones: Backlog, Go1.16 Oct 12, 2020
@twilly
Copy link

twilly commented Oct 16, 2020

I got bit by this bug where go list is used to resolve relative paths (not just the "all" special pattern).

Unfortunately go list -e is not a valid workaround as go list's output is passed along to other tools, like go vet. These tools fail if an invalid package is passed to them, hence the usefulness of list's invalid package filtering.

The only workaround I've found is to avoid passing invalid paths to go list - easier said than done. So far it means dropping empty go files into packages without any build constraints.

@golang golang locked and limited conversation to collaborators Oct 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

5 participants