golangci/golangci-lint · error

can't eval symlinks on wd

Error message

can't eval symlinks on wd %s: %w

What it means

Error from fsutils.Getwd: the cached working directory was obtained via os.Getwd but EvalSymlinks on it failed (e.g. the working directory path contains a broken symlink or was deleted). The error is cached, so all later Getwd calls in the process return the same failure.

Solutions

  1. Verify the current working directory exists and its symlinks resolve
  2. Recreate removed/renamed directories the shell still points at
  3. cd to a valid directory before running golangci-lint
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at pkg/fsutils/fsutils.go:39 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/c9e0d471c8967bdd. Report an issue: GitHub.

Appendix: source

Thrown at pkg/fsutils/fsutils.go:39

func UseWdCache(use bool) {
	useCache = use
}

func Getwd() (string, error) {
	if !useCache { // for tests
		return os.Getwd()
	}

	getWdOnce.Do(func() {
		cachedWd, cachedWdError = os.Getwd()
		if cachedWdError != nil {
			return
		}

		evaluatedWd, err := EvalSymlinks(cachedWd)
		if err != nil {
			cachedWd, cachedWdError = "", fmt.Errorf("can't eval symlinks on wd %s: %w", cachedWd, err)
			return
		}

		cachedWd = evaluatedWd
	})

	return cachedWd, cachedWdError
}

var evalSymlinkCache sync.Map

type evalSymlinkRes struct {
	path string
	err  error
}

func EvalSymlinks(path string) (string, error) {
	r, ok := evalSymlinkCache.Load(path)

View on GitHub (pinned to ed7a235d2d)