ko: ko hangs when used with ASDF installed Go
I am able to reproduce either a bug, or a misconfiguration that could perhaps use a better error message of some sort.
The reproduction is here at StevenACoffman/repro.
Repro
If you clone that repo and run:
export GOPRIVATE=github.com/StevenACoffman
cd sub
ko publish -B --bare --local --platform=linux/amd64 --push=false .
The terminal will just hang there until you hit Ctrl-c.
At which point, it will then say:
^CError: error creating builder: 'builds': entry #0 does not contain a valid local import path (./.) for directory (.): err: signal: interrupt: stderr:
2021/12/12 21:00:19 error during command execution:error creating builder: 'builds': entry #0 does not contain a valid local import path (./.) for directory (.): err: signal: interrupt: stderr:
However, if you delete the .ko.yaml file in that directory and run it again, things work as you’d expect.
rm .ko.yaml
ko publish -B --bare --local --platform=linux/amd64 --push=false .
I have tried a number of different possible values for “main” and “dir” and “id” in the .ko.yaml file, including omitting them altogether. For instance, setting the main: to the values github.com/StevenACoffman/repro/sub, ., and main don’t seem to affect this hanging behavior.
.ko.yaml contents:
# KO_DOCKER_REPO should be either kind.local
# (for KinD) or ko.local
defaultBaseImage: gcr.io/distroless/static
builds:
# You can have multiple builds defined as a yaml list
-
# ID of the build.
# Defaults to the project name.
id: "my-build"
# Path to project's (sub)directory containing Go code.
# This is the working directory for the Go build command(s).
# Default is `.`.
dir: .
# Path to main.go file or main package.
# Notice: when used with `gomod.proxy`, this must be a package.
#
# Default is `.`.
main: github.com/StevenACoffman/repro/sub
ldflags:
- -s
- -w
- -X main.AppName=Working
# Custom environment variables to be set during the builds.
# Default is empty.
env:
- CGO_ENABLED=0
Any help or tips would be greatly appreciated!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- Fix #530 Hanging behavior with ASDF installed Go on Darwin Signed-off-by: Steve Coffman <steve@khanacademy.org> — committed to StevenACoffman/ko by StevenACoffman 3 years ago
- Fix #530 Hanging behavior with ASDF installed Go on Darwin Signed-off-by: Steve Coffman <steve@khanacademy.org> — committed to StevenACoffman/ko by StevenACoffman 3 years ago
Worth mentioning that users of goenv most likely also experienced the same hanging behavior prior to the fix in #548
It’s failing in here: https://github.com/google/ko/blob/2ba70fc75bd94147b03e9c24d3e4c5f56d02edfc/pkg/commands/options/build.go#L184-L187
This is kind of a horrifying comment: https://cs.opensource.google/go/x/tools/+/refs/tags/v0.1.8:internal/gocommand/invoke.go;l=208-213;drc=27fc7644e1ac52666992274b9880c9d67e4b5a9c;bpv=1;bpt=1