golangci/golangci-lint · error

linter failed to run: %w

Error message

linter failed to run: %w

What it means

In the nolintlint analyzer wrapper, the underlying nolint linter's Run returns diagnostics plus an error; any error is wrapped as "linter failed to run" and propagates out of the analysis pass, aborting nolintlint for the package. This indicates nolintlint itself failed (internal issue), not that it found bad nolint directives.

Source

Thrown at pkg/golinters/nolintlint/nolintlint.go:45

		needs |= nolintlint.NeedsSpecific
	}
	if !settings.AllowUnused {
		needs |= nolintlint.NeedsUnused
	}

	lnt, err := nolintlint.NewLinter(needs, settings.AllowNoExplanation)
	if err != nil {
		internal.LinterLogger.Fatalf("%s: create analyzer: %v", nolintlint.LinterName, err)
	}

	return goanalysis.
		NewLinterFromAnalyzer(&analysis.Analyzer{
			Name: nolintlint.LinterName,
			Doc:  "Reports ill-formed or insufficient nolint directives",
			Run: func(pass *analysis.Pass) (any, error) {
				issues, err := lnt.Run(pass)
				if err != nil {
					return nil, fmt.Errorf("linter failed to run: %w", err)
				}

				if len(issues) == 0 {
					return nil, nil
				}

				mu.Lock()
				resIssues = append(resIssues, issues...)
				mu.Unlock()

				return nil, nil
			},
		}).
		WithIssuesReporter(func(*linter.Context) []*goanalysis.Issue {
			return resIssues
		}).
		WithLoadMode(goanalysis.LoadModeSyntax)
}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Update golangci-lint to the latest release to pick up nolintlint fixes.
  2. Reformat the suspicious //nolint comments (e.g. //nolint:lintname // reason form) and re-run.
  3. Exclude the problematic files via skip-files or disable nolintlint temporarily to unblock CI.
  4. Reproduce with the wrapped %w cause and file an issue on golangci-lint if it persists.

Example fix

// before
foo() //nolint
// after
foo() //nolint:errcheck // intentional ignore
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-lint: run with --no-config on a copy of the package to isolate whether nolintlint config/comments trigger the failure

Try / catch

if err := nolintlintRun(pass); err != nil {
    log.Printf("nolintlint failed: %v", errors.Unwrap(err))
    // degrade gracefully: continue lint run without nolintlint results
}

Prevention

When it happens

Trigger: lnt.Run(pass) returns a non-nil error while the nolintlint analyzer processes a package — e.g. internal directive-parsing failures, unexpected AST/position state, or bugs in the nolint library on edge-case comments.

Common situations: Malformed or exotic //nolint comment combinations triggering library edge cases; running a golangci-lint version with a known nolintlint bug; packages with unusual comment positioning (cgo, generated code).

Related errors


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