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

Build fails on packages that have build tags that cause no source #1

Open
abatilo opened this issue Jul 1, 2020 · 2 comments
Open

Comments

@abatilo
Copy link

abatilo commented Jul 1, 2020

Basically, go get fails under these circumstances:
golang/go#33526

@montanaflynn
Copy link
Owner

Do you have example error logs or a package that I can reproduce it with?

@abatilo
Copy link
Author

abatilo commented Jul 3, 2020

I do!

https://gist.github.com/abatilo/174d63a893984803dca9bf728d12e524

The grpc project imports protobuf indirectly and protobuf doesn't have any go files due to build constraints.

You end up with:

⇒  docker build -t cache-failure .
Sending build context to Docker daemon  12.29kB
Step 1/6 : FROM golang:1.14-alpine as backend
 ---> 3289bf11c284
Step 2/6 : RUN CGO_ENABLED=0 GOOS=linux go install -v -a std
 ---> Using cache
 ---> 3db60d6a579f
Step 3/6 : WORKDIR /go/src/cache-failure
 ---> Using cache
 ---> 5b7ec77afa0f
Step 4/6 : COPY ./go.mod ./go.sum ./
 ---> Using cache
 ---> 266966f657d9
Step 5/6 : SHELL ["/bin/ash", "-o", "pipefail", "-c"]
 ---> Using cache
 ---> c9f6bf08680d
Step 6/6 : RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get -v
 ---> Running in 7ed8d0467fb8
go: downloading google.golang.org/protobuf v1.25.0
go: downloading google.golang.org/grpc v1.27.0
go: downloading golang.org/x/net v0.0.0-20190311183353-d8887717615a
go: downloading google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
go: downloading github.com/golang/protobuf v1.4.1
go: downloading golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: downloading golang.org/x/text v0.3.0
go get google.golang.org/[email protected]: no Go source files
The command '/bin/ash -o pipefail -c go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get -v' returned a non-zero code: 123

I've kind of hacked around the failure by switching the line to:

RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs -I{} ash -c "go get -v {} || true"

There might be a better option but I'm not sure of one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants