{"record":{"id":"9070ec4b19fd104a","repo":"golangci/golangci-lint","slug":"failed-to-get-enabled-linters-w","errorCode":null,"errorMessage":"failed to get enabled linters: %w","messagePattern":"failed to get enabled linters: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/lint/runner.go","lineNumber":52,"sourceCode":"}\n\nfunc NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env,\n\tlineCache *fsutils.LineCache, fileCache *fsutils.FileCache,\n\tdbManager *lintersdb.Manager, lintCtx *linter.Context,\n) (*Runner, error) {\n\tpathRelativity, err := processors.NewPathRelativity(log, cfg.GetBasePath())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating path relativity processor: %w\", err)\n\t}\n\n\texclusionPaths, err := processors.NewExclusionPaths(log, &cfg.Linters.Exclusions)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tenabledLinters, err := dbManager.GetEnabledLintersMap()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get enabled linters: %w\", err)\n\t}\n\n\tvar enabledFormatters []string\n\tfor name := range maps.Keys(enabledLinters) {\n\t\tif goformatters.IsFormatter(name) {\n\t\t\tenabledFormatters = append(enabledFormatters, name)\n\t\t}\n\t}\n\n\tswitch len(enabledLinters) {\n\tcase 0:\n\t\treturn nil, errors.New(\"no linters enabled\")\n\tcase 1:\n\t\tif _, ok := enabledLinters[\"typecheck\"]; ok {\n\t\t\treturn nil, errors.New(\"no linters enabled\")\n\t\t}\n\t}\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/lint/runner.go#L34-L70","documentation":"NewRunner asks the lintersdb Manager for the map of enabled linters (GetEnabledLintersMap). If that validation fails — most commonly mutually exclusive linters or invalid preset/enable combinations — the runner cannot be built and the error is wrapped as \"failed to get enabled linters\".","triggerScenarios":"Configuration that GetEnabledLintersMap rejects: enabling linters that cannot run together (e.g. enabling both exclusive linters like gofmt/goimports conflicts in formatter mode), enabling a disabled-by-default preset combination, or enabling unknown linters that passed earlier validation but conflict here.","commonSituations":"Copy-pasted .golangci.yml enabling two incompatible linters; combining `--fast` with linters that have no fast variant; presets mixed with explicit enable lists that overlap conflicts.","solutions":["Read the wrapped cause — it names the conflicting linters or invalid combination","Remove one of the mutually exclusive linters from `linters.enable` in .golangci.yml","If presets conflict with explicit enables, drop the preset or the overlapping names","Run `golangci-lint config verify` (or `linters` command) to validate the config before running"],"exampleFix":"// before (.golangci.yml)\nlinters:\n  enable:\n    - gofmt\n    - gofumpt   # conflicting formatters\n// after\nlinters:\n  enable:\n    - gofumpt","handlingStrategy":"validation","validationCode":"// Validate the enabled-linter set before running:\n// golangci-lint cache status\n// golangci-lint config verify\n// golangci-lint linters | grep -E '<enabled names>'  # confirm each resolves and isn't exclusive","typeGuard":null,"tryCatchPattern":"enabled, err := dbManager.GetEnabledLintersMap()\nif err != nil {\n    return fmt.Errorf(\"failed to get enabled linters: %w\", err)\n}","preventionTips":["Never combine mutually exclusive linters (e.g. multiple gofmt-family formatters) in `linters.enable`","Validate config in CI with `golangci-lint config verify` on every change","Avoid mixing presets with hand-picked enables without checking overlaps","Read the wrapped error's cause; it explicitly names the conflict"],"tags":["golangci-lint","configuration","linters"],"backgroundTag":"linter-conflict","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}