goreleaser/goreleaser · error

could not find '%s' absolute path: %w

Error message

could not find '%s' absolute path: %w

What it means

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.

Source

Thrown at internal/builders/golang/gomain/gomain.go:84

	}
	return ErrNoMain{binary}
}

const mode = packages.NeedName |
	packages.NeedTypes |
	packages.NeedSyntax |
	packages.NeedTypesInfo |
	packages.NeedDeps |
	packages.NeedFiles |
	packages.NeedModule

// All finds all the `func main`'s in the given dir following the given patterns.
// The result is either a map of binaryName -> ./relative/path or an error.
// This only works on a go module.
func All(dir string, patterns ...string) (map[string]string, error) {
	absDir, err := filepath.Abs(dir)
	if err != nil {
		return nil, fmt.Errorf("could not find '%s' absolute path: %w", dir, err)
	}

	cfg := &packages.Config{
		Mode: mode,
		Dir:  absDir,
	}
	pkgs, err := packages.Load(cfg, patterns...)
	if err != nil {
		return nil, fmt.Errorf("could not load packages: %w", err)
	}

	result := make(map[string]string) // binaryName → dir
	for _, pkg := range pkgs {
		if pkg.Name != "main" {
			continue
		}

		if !hasMainFunc(pkg) {

View on GitHub (pinned to f5edd73956)

Solutions

  1. Run the command from an existing, readable working directory (`cd` to the repo root)
  2. Pass an absolute `dir` to All instead of a relative one
  3. Verify the working directory exists: `pwd` should succeed
  4. Re-create the deleted directory or re-clone the repository
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the working directory and target dir resolve before calling All
if _, err := os.Getwd(); err != nil {
    return fmt.Errorf("working directory unavailable: %w", err)
}
abs, err := filepath.Abs(dir)
if err != nil {
    return fmt.Errorf("cannot resolve %s: %w", dir, err)
}
if fi, err := os.Stat(abs); err != nil || !fi.IsDir() {
    return fmt.Errorf("%s is not an accessible directory", abs)
}

Type guard

func resolvableDir(dir string) bool {
    abs, err := filepath.Abs(dir)
    if err != nil {
        return false
    }
    fi, err := os.Stat(abs)
    return err == nil && fi.IsDir()
}

Try / catch

mains, err := gomain.All(dir, patterns...)
if err != nil {
    if strings.Contains(err.Error(), "absolute path") {
        log.Printf("cannot resolve dir %q; cwd may be deleted", dir)
    }
    return err
}

Prevention

When it happens

Trigger: Calling All with a relative `dir` while the process's current working directory no longer exists (deleted or unreadable), causing filepath.Abs to fail.

Common situations: 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.

Related errors


AI-assisted analysis of goreleaser/goreleaser@f5edd73956 (2026-09-05). Data as JSON: /api/errors/9f86dd4a5043c602. Report an issue: GitHub.