{"record":{"id":"2eadca7345383d4b","repo":"goreleaser/goreleaser","slug":"ko-s-does-not-contain-a-valid-local-import-path","errorCode":null,"errorMessage":"ko: %s does not contain a valid local import path (%s) for directory (%s): %w","messagePattern":"ko: (.+?) does not contain a valid local import path \\((.+?)\\) for directory \\((.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pipe/ko/ko.go","lineNumber":403,"sourceCode":"\nfunc buildBuildOptions(ctx *context.Context, cfg config.Ko) (*buildOptions, error) {\n\tlocalImportPath := cfg.Main\n\tif localImportPath == \"\" {\n\t\t// ko.main is optional, and go1.27+ rejects an empty package pattern.\n\t\tlocalImportPath = \".\"\n\t}\n\n\tdir := filepath.Clean(cfg.WorkingDir)\n\tif dir == \".\" {\n\t\tdir = \"\"\n\t}\n\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tMode: packages.NeedName,\n\t\tDir:  dir,\n\t}, localImportPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"ko: %s does not contain a valid local import path (%s) for directory (%s): %w\",\n\t\t\tcfg.ID, localImportPath, cfg.WorkingDir, err,\n\t\t)\n\t}\n\n\tif len(pkgs) != 1 {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"ko: %s results in %d local packages, only 1 is expected\",\n\t\t\tcfg.ID, len(pkgs),\n\t\t)\n\t}\n\n\topts := &buildOptions{\n\t\timportPath:          pkgs[0].PkgPath,\n\t\tworkingDir:          cfg.WorkingDir,\n\t\tbare:                cfg.Bare,\n\t\tpreserveImportPaths: cfg.PreserveImportPaths,\n\t\tbaseImportPaths:     cfg.BaseImportPaths,","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/goreleaser/goreleaser/blob/f5edd7395693c0c6b501dc722d445d2e86af854d/internal/pipe/ko/ko.go#L385-L421","documentation":"buildBuildOptions uses golang.org/x/tools/go/packages to resolve ko.main (or \".\" if empty) into a local import path relative to ko.working_dir; packages.Load itself errored, so goreleaser reports that the directory does not contain a valid local import path, wrapping the underlying load error.","triggerScenarios":"packages.Load fails for the given pattern/dir: no Go module in working_dir, invalid pattern syntax, missing go.sum entries, or tooling errors loading the package graph.","commonSituations":"ko.main points at a directory with no Go files; running outside a module (no go.mod); corrupted module cache; typo in ko.main pattern like \"./cmmd\".","solutions":["Run `go list ./...` (or `go list <pattern>`) in ko.working_dir to reproduce and see the raw error","Fix ko.main to a valid package pattern (e.g. ./cmd/app) or remove it to default to \".\"","Ensure go.mod exists in working_dir","Run `go mod tidy` if go.sum/module errors appear"],"exampleFix":"// before\nkos:\n  - main: ./ap\n// after\nkos:\n  - main: ./cmd/app","handlingStrategy":"validation","validationCode":"cd \"$(yq '.kos[0].working_dir // \".\"' .goreleaser.yaml)\" && go list \"$(yq '.kos[0].main // \".\"' .goreleaser.yaml)\" >/dev/null || echo 'ko.main unresolvable'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `go list <ko.main>` in CI before release","Keep go.mod/go.sum committed and tidy","Prefer explicit package dirs over broad patterns"],"tags":["ko","go","packages","configuration"],"backgroundTag":"invalid-import-path","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"}