{"record":{"id":"9f86dd4a5043c602","repo":"goreleaser/goreleaser","slug":"could-not-find-s-absolute-path-w","errorCode":null,"errorMessage":"could not find '%s' absolute path: %w","messagePattern":"could not find '(.+?)' absolute path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/builders/golang/gomain/gomain.go","lineNumber":84,"sourceCode":"\t}\n\treturn ErrNoMain{binary}\n}\n\nconst mode = packages.NeedName |\n\tpackages.NeedTypes |\n\tpackages.NeedSyntax |\n\tpackages.NeedTypesInfo |\n\tpackages.NeedDeps |\n\tpackages.NeedFiles |\n\tpackages.NeedModule\n\n// All finds all the `func main`'s in the given dir following the given patterns.\n// The result is either a map of binaryName -> ./relative/path or an error.\n// This only works on a go module.\nfunc All(dir string, patterns ...string) (map[string]string, error) {\n\tabsDir, err := filepath.Abs(dir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not find '%s' absolute path: %w\", dir, err)\n\t}\n\n\tcfg := &packages.Config{\n\t\tMode: mode,\n\t\tDir:  absDir,\n\t}\n\tpkgs, err := packages.Load(cfg, patterns...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not load packages: %w\", err)\n\t}\n\n\tresult := make(map[string]string) // binaryName → dir\n\tfor _, pkg := range pkgs {\n\t\tif pkg.Name != \"main\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tif !hasMainFunc(pkg) {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/goreleaser/goreleaser/blob/f5edd7395693c0c6b501dc722d445d2e86af854d/internal/builders/golang/gomain/gomain.go#L66-L102","documentation":"gomain.All converts the given directory to an absolute path with filepath.Abs before loading packages; this error is returned when that conversion fails. filepath.Abs rarely fails — it fails only when computing the working directory (for relative inputs) returns an error, e.g. the current working directory was deleted.","triggerScenarios":"Calling All with a relative `dir` while the process's current working directory no longer exists (deleted or unreadable), causing filepath.Abs to fail.","commonSituations":"Running goreleaser from a directory that was removed or replaced by a symlink chain that no longer resolves; running in a container where WORKDIR was deleted; CI checking out into a path that is unlinked mid-run.","solutions":["Run the command from an existing, readable working directory (`cd` to the repo root)","Pass an absolute `dir` to All instead of a relative one","Verify the working directory exists: `pwd` should succeed","Re-create the deleted directory or re-clone the repository"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure the working directory and target dir resolve before calling All\nif _, err := os.Getwd(); err != nil {\n    return fmt.Errorf(\"working directory unavailable: %w\", err)\n}\nabs, err := filepath.Abs(dir)\nif err != nil {\n    return fmt.Errorf(\"cannot resolve %s: %w\", dir, err)\n}\nif fi, err := os.Stat(abs); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"%s is not an accessible directory\", abs)\n}","typeGuard":"func resolvableDir(dir string) bool {\n    abs, err := filepath.Abs(dir)\n    if err != nil {\n        return false\n    }\n    fi, err := os.Stat(abs)\n    return err == nil && fi.IsDir()\n}","tryCatchPattern":"mains, err := gomain.All(dir, patterns...)\nif err != nil {\n    if strings.Contains(err.Error(), \"absolute path\") {\n        log.Printf(\"cannot resolve dir %q; cwd may be deleted\", dir)\n    }\n    return err\n}","preventionTips":["Pass absolute paths to All from long-running services","Avoid deleting/replacing the process working directory while running","In containers, ensure WORKDIR exists for the lifetime of the command","Check `pwd` works before invoking release tooling in shell scripts"],"tags":["go","filesystem","path"],"backgroundTag":"invalid-working-directory","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"}