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

ko uses "go" as default GOROOT, causing build errors #218

Open
antoineco opened this issue Oct 7, 2020 · 4 comments
Open

ko uses "go" as default GOROOT, causing build errors #218

antoineco opened this issue Oct 7, 2020 · 4 comments

Comments

@antoineco
Copy link

@antoineco antoineco commented Oct 7, 2020

Description

ko uses "go" as GOROOT when GOROOT is not exported in the environment, instead of defaulting to $(go env GOROOT). This prevents builds from happening.

In the previous version, the error message was quite explicit: "go: cannot find GOROOT directory: go".

Now, in 0.6.0, the error is much more ambiguous: importpath "ko://knative.dev/serving/cmd/controller" is not supported.

ko version

$ ko  version
0.6.0

How to reproduce

Example, inside https://github.com/knative/serving/

$ printenv GOROOT  # empty
$ ko publish -L ./cmd/controller  # failure
2020/10/07 12:41:33 failed to publish images: importpath "ko://knative.dev/serving/cmd/controller" is not supported
$ export GOROOT="$(go env GOROOT)"
$ printenv GOROOT
/usr/local/go
$ ko publish -L ./cmd/controller  # success
2020/10/07 12:45:13 Using base gcr.io/distroless/static:nonroot for knative.dev/serving/cmd/controller
2020/10/07 12:45:15 Building knative.dev/serving/cmd/controller for linux/amd64
[...]

Temporary workaround

Add this line to your .*shrc file:

export GOROOT="${GOROOT:-$(go env GOROOT)}"
antoineco added a commit to antoineco/dotfiles that referenced this issue Oct 7, 2020
Prevents ko tool from throwing "go: cannot find GOROOT directory: go"

google/ko#218
@mattmoor
Copy link
Collaborator

@mattmoor mattmoor commented Oct 7, 2020

I think @scothis has an open issue for this, and I think @jonjohnsonjr has the most context on this issue.

@scothis
Copy link

@scothis scothis commented Oct 7, 2020

@mattmoor #106

@antoineco
Copy link
Author

@antoineco antoineco commented Oct 7, 2020

@scothis do I understand correctly that ko just needs to be rebuilt (e.g. via go get) for GOROOT to default to the expected value?

@mattmoor
Copy link
Collaborator

@mattmoor mattmoor commented Oct 7, 2020

Unfortunately go get ignores replace directives in go.mod, so I'd recommend go install.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.