{"record":{"id":"36a4a6c82f20a154","repo":"goreleaser/goreleaser","slug":"ko-missing-repositories-please-set-either-the-re","errorCode":null,"errorMessage":"ko: missing repositories: please set either the repository field or a $KO_DOCKER_REPO environment variable","messagePattern":"ko: missing repositories: please set either the repository field or a \\$KO_DOCKER_REPO environment variable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pipe/ko/ko.go","lineNumber":58,"sourceCode":"\t\"github.com/goreleaser/goreleaser/v2/pkg/context\"\n\t\"golang.org/x/tools/go/packages\"\n)\n\nconst chainguardStatic = \"cgr.dev/chainguard/static\"\n\nvar (\n\tbaseImages     sync.Map\n\tamazonKeychain authn.Keychain = authn.NewKeychainFromHelper(ecr.NewECRHelper(ecr.WithLogger(io.Discard)))\n\tazureKeychain  authn.Keychain = authn.NewKeychainFromHelper(credhelper.NewACRCredentialsHelper())\n\tkeychain                      = authn.NewMultiKeychain(\n\t\tamazonKeychain,\n\t\tauthn.DefaultKeychain,\n\t\tgoogle.Keychain,\n\t\tgithub.Keychain,\n\t\tazureKeychain,\n\t)\n\n\terrNoRepositories    = errors.New(\"ko: missing repositories: please set either the repository field or a $KO_DOCKER_REPO environment variable\")\n\terrInvalidMainPath   = errors.New(\"ko: invalid Main path: ko.main (or build.main if ko.main is not set) should be a relative path\")\n\terrInvalidMainGoPath = errors.New(\"ko: invalid Main path: your path should point to a directory instead of a .go file\")\n)\n\n// Pipe that build OCI compliant images with ko.\ntype Pipe struct{}\n\nfunc (Pipe) String() string { return \"ko\" }\nfunc (Pipe) Skip(ctx *context.Context) bool {\n\treturn skips.Any(ctx, skips.Ko) || len(ctx.Config.Kos) == 0\n}\n\n// Default sets the Pipes defaults.\nfunc (Pipe) Default(ctx *context.Context) error {\n\tids := ids.New(\"kos\")\n\tfor i := range ctx.Config.Kos {\n\t\tko := &ctx.Config.Kos[i]\n\t\tif ko.ID == \"\" {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/goreleaser/goreleaser/blob/f5edd7395693c0c6b501dc722d445d2e86af854d/internal/pipe/ko/ko.go#L40-L76","documentation":"The ko pipe needs to know which container registry/repository to push images to. ko determines this from the ko.repository config field or the $KO_DOCKER_REPO environment variable; when neither is set, no repositories can be resolved and Default/buildBuildOptions (and Run) fail with errNoRepositories.","triggerScenarios":"ko section present in .goreleaser.yaml (or ko used in tests) with no repository field and no KO_DOCKER_REPO env var set; also at internal/pipe/ko/ko.go:442 when opts.imageRepos ends up empty after option building.","commonSituations":"CI environments where KO_DOCKER_REPO is not exported; adding a ko section but only setting base_image_importpath; forgetting the repository key when migrating from another image pipe.","solutions":["Set repository in the ko section of .goreleaser.yaml (e.g. repository: ghcr.io/user/app)","Or export KO_DOCKER_REPO=registry/repo in the build environment","Re-run goreleaser after setting either value"],"exampleFix":"# before (goreleaser.yaml)\nko:\n  build: build\n# after\nko:\n  build: build\n  repository: ghcr.io/myorg/myapp","handlingStrategy":"validation","validationCode":"if ko.Repository == \"\" && os.Getenv(\"KO_DOCKER_REPO\") == \"\" {\n    return errors.New(\"ko: set ko.repository or KO_DOCKER_REPO before releasing\")\n}","typeGuard":null,"tryCatchPattern":"if err := koPipe.Default(ctx); err != nil {\n    if errors.Is(err, ko.ErrNoRepositories) {\n        return fmt.Errorf(\"configure ko.repository in .goreleaser.yaml or export KO_DOCKER_REPO: %w\", err)\n    }\n    return err\n}","preventionTips":["Always set repository in the ko section of .goreleaser.yaml","Export KO_DOCKER_REPO in CI job environment as a fallback","Run goreleaser check / a snapshot build before real releases"],"tags":["goreleaser","ko","container-image","missing-config"],"backgroundTag":"missing-config-field","analyzedSha":"f5edd7395693c0c6b501dc722d445d2e86af854d","analyzedAt":"2026-09-05T09:57:18.807Z","contentChangedAt":"2026-09-05T09:57:18.807Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}