{"record":{"id":"edf40bbe78215cea","repo":"golangci/golangci-lint","slug":"failed-to-pre-run-s-w","errorCode":null,"errorMessage":"failed to pre-run %s: %w","messagePattern":"failed to pre-run (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/goanalysis/metalinter.go","lineNumber":27,"sourceCode":"\t\"github.com/golangci/golangci-lint/v2/pkg/lint/linter\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/result\"\n)\n\ntype MetaLinter struct {\n\tlinters              []*Linter\n\tanalyzerToLinterName map[*analysis.Analyzer]string\n}\n\nfunc NewMetaLinter(linters []*Linter) *MetaLinter {\n\tml := &MetaLinter{linters: linters}\n\tml.analyzerToLinterName = ml.getAnalyzerToLinterNameMapping()\n\treturn ml\n}\n\nfunc (ml MetaLinter) Run(_ context.Context, lintCtx *linter.Context) ([]*result.Issue, error) {\n\tfor _, l := range ml.linters {\n\t\tif err := l.preRun(lintCtx); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to pre-run %s: %w\", l.Name(), err)\n\t\t}\n\t}\n\n\treturn runAnalyzers(ml, lintCtx)\n}\n\nfunc (MetaLinter) Name() string {\n\treturn \"goanalysis_metalinter\"\n}\n\nfunc (MetaLinter) Desc() string {\n\treturn \"\"\n}\n\nfunc (ml MetaLinter) getLoadMode() LoadMode {\n\tloadMode := LoadModeNone\n\tfor _, l := range ml.linters {\n\t\tif l.loadMode > loadMode {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/goanalysis/metalinter.go#L9-L45","documentation":"golangci-lint's MetaLinter.Run wraps any error returned by an individual linter's preRun hook. preRun is executed once per enabled linter before analysis (e.g. to build package maps or load type information). The %w preserves the underlying cause; the %s names which linter failed.","triggerScenarios":"Running golangci-lint with a linter whose preRun hook fails — e.g. a linter cannot load packages/types during its setup phase; Run() is invoked with a linter.Context and one of ml.linters returns a non-nil error from preRun(lintCtx).","commonSituations":"Enabling linters in .golangci.yml that require build tags, GOPATH/module layout or generated code that doesn't resolve; typecheck failures in the analyzed packages surfacing through a linter's setup step; incompatible linter/plugin versions after upgrading golangci-lint.","solutions":["Run `golangci-lint cache clean` and re-run to rule out stale analysis cache","Read the wrapped cause after 'failed to pre-run <name>:' and fix the underlying linter-specific issue (usually package loading/typecheck errors)","Disable the offending linter in .golangci.yml to confirm which one fails, then re-enable only after fixing","Check that all packages compile (`go build ./...`) before linting; preRun often fails on non-compiling code"],"exampleFix":"// before (.golangci.yml) - linter fails in pre-run due to bad config\nlinters:\n  enable: [govet, staticcheck, custom-linter]\n// after - disable/reconfigure the failing linter or fix config\nlinters:\n  enable: [govet, staticcheck]\n  settings:\n    custom-linter:\n      path: ./correct-plugin-path.so","handlingStrategy":"try-catch","validationCode":"// shell check before invoking golangci-lint\nif ! go build ./...; then echo 'fix compile errors before linting'; fi","typeGuard":null,"tryCatchPattern":"// wrap CLI run and inspect wrapped cause\nout, err := runGolangciLint()\nif err != nil {\n    var prerunErr *LinterPrerunError // or match on \"failed to pre-run\"\n    if strings.Contains(err.Error(), \"failed to pre-run \") {\n        linterName := extractBetween(err.Error(), \"failed to pre-run \", \":\")\n        log.Printf(\"disabling broken linter: %s\", linterName)\n        // retry without that linter\n    }\n    return err\n}","preventionTips":["Keep .golangci.yml minimal; enable linters incrementally and verify each","Ensure `go build ./...` passes before every lint run in CI","Pin the golangci-lint version and keep linter configs compatible with it","Run `golangci-lint cache clean` after toolchain upgrades"],"tags":["golangci-lint","linting","go","prerun"],"backgroundTag":"linter-prerun-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}