golangci/golangci-lint · error

can't eval symlinks for path %s: %w

Error message

can't eval symlinks for path %s: %w

What it means

Wrapping error in ShortestRelPath: EvalSymlinks(path) failed for the target path — a symlink component is broken or the path does not exist — so the path cannot be normalized to its shortest relative form.

Source

Thrown at pkg/fsutils/fsutils.go:81

	var er evalSymlinkRes
	er.path, er.err = evalSymlinks(path)
	evalSymlinkCache.Store(path, er)

	return er.path, er.err
}

func ShortestRelPath(path, wd string) (string, error) {
	if wd == "" { // get it if user don't have cached working dir
		var err error
		wd, err = Getwd()
		if err != nil {
			return "", fmt.Errorf("can't get working directory: %w", err)
		}
	}

	evaluatedPath, err := EvalSymlinks(path)
	if err != nil {
		return "", fmt.Errorf("can't eval symlinks for path %s: %w", path, err)
	}
	path = evaluatedPath

	// make path absolute and then relative to be able to fix this case:
	// we are in `/test` dir, we want to normalize `../test`, and have file `file.go` in this dir;
	// it must have normalized path `file.go`, not `../test/file.go`,
	var absPath string
	if filepath.IsAbs(path) {
		absPath = path
	} else {
		absPath = filepath.Join(wd, path)
	}

	relPath, err := filepath.Rel(wd, absPath)
	if err != nil {
		return "", fmt.Errorf("can't get relative path for path %s and root %s: %w",
			absPath, wd, err)
	}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Verify the path exists and all symlink components resolve
  2. Remove or fix broken symlinks
  3. Check the path is not deleted between listing and processing
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at pkg/fsutils/fsutils.go:81 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/88e35be05badeeba. Report an issue: GitHub.