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

Fix GOROOT mismatch issues #303

Merged
merged 1 commit into from
Jan 21, 2021
Merged

Conversation

jonjohnsonjr
Copy link
Collaborator

Print a warning if GOROOT is unset and ko's default build context
differs from $(go env GOROOT) and use the result of $(go env GOROOT).

Fixes #106

Print a warning if GOROOT is unset and ko's default build context
differs from $(go env GOROOT) and use the result of $(go env GOROOT).
@jonjohnsonjr
Copy link
Collaborator Author

I'm open to opinions here about warning or not warning or whatever, let me know how you feel about spamming stderr.

I worry that just inferring this automatically might break things that worked before without any kind of warning.

@codecov-io
Copy link

Codecov Report

Merging #303 (fd44e27) into master (3c21033) will decrease coverage by 0.03%.
The diff coverage is 38.46%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #303      +/-   ##
==========================================
- Coverage   38.10%   38.07%   -0.04%     
==========================================
  Files          33       33              
  Lines        1501     1513      +12     
==========================================
+ Hits          572      576       +4     
- Misses        839      844       +5     
- Partials       90       93       +3     
Impacted Files Coverage Δ
pkg/build/gobuild.go 59.71% <38.46%> (-0.96%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c21033...fd44e27. Read the comment docs.

@jonjohnsonjr
Copy link
Collaborator Author

Here I have modified my ko binary to have the wrong embedded GOROOT, as a demonstration of this warning in action:

$ sed -i '0,/go-1.15.5/s//jasonhall/' $(which ko)
$ ko publish .
2021/01/21 10:12:19 NOTICE!
-----------------------------------------------------------------
ko and go have mismatched GOROOT:
    go/build.Default.GOROOT = "/nix/store/1drmsvcyf0mlzhs3yzwblrwhv4hvqkkx-jasonhall/share/go"
    $(go env GOROOT) = "/nix/store/1drmsvcyf0mlzhs3yzwblrwhv4hvqkkx-go-1.15.5/share/go"

Inferring GOROOT="/nix/store/1drmsvcyf0mlzhs3yzwblrwhv4hvqkkx-go-1.15.5/share/go"

Run this to remove this warning:
    export GOROOT=$(go env GOROOT)

For more information see:
    https://github.com/google/ko/issues/106
-----------------------------------------------------------------
2021/01/21 10:12:20 Using base gcr.io/distroless/static:nonroot for github.com/google/ko
2021/01/21 10:12:21 Building github.com/google/ko for linux/amd64
2021/01/21 10:12:24 Publishing gcr.io/jonjohnson-test/ko/ko-98b8c7facdad74510a7cae0cd368eb4e:latest
2021/01/21 10:12:24 existing blob: sha256:72164b581b02b1eb297b403bcc8fc1bfa245cb52e103a3a525a0835a58ff58e2
2021/01/21 10:12:24 existing blob: sha256:d9662fda187c24492976489da64d81b5a6f034440d15c89c461cd8bb357f697d
2021/01/21 10:12:24 existing blob: sha256:5749e56bea7178768b00aac0bf087558fccd5b8e0c807610618be7568459f359
2021/01/21 10:12:24 existing blob: sha256:7d05b95b5288b7f76d3f2c5531254685d54c0c28867cb6365e96cd5774c130d6
2021/01/21 10:12:25 gcr.io/jonjohnson-test/ko/ko-98b8c7facdad74510a7cae0cd368eb4e:latest: digest: sha256:5496539d4d4eb8b0939cf8528fa8599f688e50c21d385d7f81de90e6c5f78a0a size: 750
2021/01/21 10:12:25 Published gcr.io/jonjohnson-test/ko/ko-98b8c7facdad74510a7cae0cd368eb4e@sha256:5496539d4d4eb8b0939cf8528fa8599f688e50c21d385d7f81de90e6c5f78a0a
gcr.io/jonjohnson-test/ko/ko-98b8c7facdad74510a7cae0cd368eb4e@sha256:5496539d4d4eb8b0939cf8528fa8599f688e50c21d385d7f81de90e6c5f78a0a

@jonjohnsonjr
Copy link
Collaborator Author

docker: Error response from daemon: Get https://registry-1.docker.io/v2/library/registry/manifests/2: received unexpected HTTP status: 502 Bad Gateway.

Fantastic.

@jonjohnsonjr jonjohnsonjr merged commit 82cabb4 into ko-build:master Jan 21, 2021
@jonjohnsonjr jonjohnsonjr deleted the go-env-goroot branch January 21, 2021 18:30
@vdemeester
Copy link
Contributor

Thanks for this @jonjohnsonjr 😻

@benmoss
Copy link
Contributor

benmoss commented Feb 3, 2021

I'm seeing this error now and do not understand it

foo | starting build (using ko): ./cmd/kbld
foo | 2021/02/03 15:54:53 NOTICE!
foo | -----------------------------------------------------------------
foo | ko and go have mismatched GOROOT:
foo |     go/build.Default.GOROOT = "go"
foo |     $(go env GOROOT) = "/usr/local/go"
foo |
foo | Inferring GOROOT="/usr/local/go"
foo |
foo | Run this to remove this warning:
foo |     export GOROOT=$(go env GOROOT)
foo |
foo | For more information see:
foo |     https://github.com/google/ko/issues/106
foo | -----------------------------------------------------------------

I'm using the ko binary from the GitHub releases

@vdemeester
Copy link
Contributor

@benmoss it's a warning, not an error. Basically it's telling you it is inferring GOROOT to be /usr/local/go. If that's not the case or if we way to remove the warning, you need to set the GOROOT env variable

@jonjohnsonjr
Copy link
Collaborator Author

Yep, I've also filed #305 as a path forward for removing this warning altogether.

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

Successfully merging this pull request may close these issues.

ko stops building containers after Golang updates
6 participants