golangci/golangci-lint · error

error creating path relativity processor: %w

Error message

error creating path relativity processor: %w

What it means

NewRunner constructs the processor chain; the first processor, NewPathRelativity (which converts absolute paths to paths relative to the configured base path), can fail if the base path configuration is invalid. The error is wrapped as "error creating path relativity processor", aborting runner creation before any linting happens.

Source

Thrown at pkg/lint/runner.go:42

type processorStat struct {
	inCount  int
	outCount int
}

type Runner struct {
	Log logutils.Log

	lintCtx    *linter.Context
	Processors []processors.Processor
}

func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env,
	lineCache *fsutils.LineCache, fileCache *fsutils.FileCache,
	dbManager *lintersdb.Manager, lintCtx *linter.Context,
) (*Runner, error) {
	pathRelativity, err := processors.NewPathRelativity(log, cfg.GetBasePath())
	if err != nil {
		return nil, fmt.Errorf("error creating path relativity processor: %w", err)
	}

	exclusionPaths, err := processors.NewExclusionPaths(log, &cfg.Linters.Exclusions)
	if err != nil {
		return nil, err
	}

	enabledLinters, err := dbManager.GetEnabledLintersMap()
	if err != nil {
		return nil, fmt.Errorf("failed to get enabled linters: %w", err)
	}

	var enabledFormatters []string
	for name := range maps.Keys(enabledLinters) {
		if goformatters.IsFormatter(name) {
			enabledFormatters = append(enabledFormatters, name)
		}
	}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Check `run.relative-path-mode` and path-related settings in .golangci.yml; reset them to defaults (`relative-path-mode: gomod`) to test
  2. Ensure the working directory where golangci-lint runs exists and is the module root
  3. Remove custom base-path/output configuration and add back incrementally until the failure reappears
  4. Inspect the wrapped %w cause — it names the exact filesystem/validation failure

Example fix

// before (.golangci.yml)
run:
  relative-path-mode: custom-invalid-value
// after
run:
  relative-path-mode: gomod
Defensive patterns

Strategy: validation

Validate before calling

// Validate path settings before running:
// grep -E 'relative-path-mode|output' .golangci.yml
// test -d . || exit 1   # ensure working dir exists
// golangci-lint config verify || exit 1

Try / catch

if err := processors.NewPathRelativity(log, basePath); err != nil {
    return fmt.Errorf("error creating path relativity processor: %w", err)
}

Prevention

When it happens

Trigger: Calling NewRunner with a config whose cfg.GetBasePath() resolves to a path the processor cannot handle (e.g. a path that does not exist, or invalid output-path/relative-path-mode settings producing a bad base path).

Common situations: Setting `run.relative-path-mode` or output path options to unusual values; running inside containers/CI where the working directory differs from the configured base path; custom builds passing a wrong cfg.

Related errors


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