{"record":{"id":"b6da589896a27a69","repo":"golangci/golangci-lint","slug":"can-t-get-enabled-linters-w","errorCode":null,"errorMessage":"can't get enabled linters: %w","messagePattern":"can't get enabled linters: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/linters.go","lineNumber":93,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"can't load config: %w\", err)\n\t}\n\n\tdbManager, err := lintersdb.NewManager(c.log.Child(logutils.DebugKeyLintersDB), c.cfg,\n\t\tlintersdb.NewLinterBuilder(), lintersdb.NewPluginModuleBuilder(c.log), lintersdb.NewPluginGoBuilder(c.log))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.dbManager = dbManager\n\n\treturn nil\n}\n\nfunc (c *lintersCommand) execute(_ *cobra.Command, _ []string) error {\n\tenabledLintersMap, err := c.dbManager.GetEnabledLintersMap()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"can't get enabled linters: %w\", err)\n\t}\n\n\tvar enabledLinters []*linter.Config\n\tvar disabledLinters []*linter.Config\n\n\tfor _, lc := range c.dbManager.GetAllSupportedLinterConfigs() {\n\t\tif lc.Internal {\n\t\t\tcontinue\n\t\t}\n\n\t\tif goformatters.IsFormatter(lc.Name()) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif enabledLintersMap[lc.Name()] == nil {\n\t\t\tdisabledLinters = append(disabledLinters, lc)\n\t\t} else {\n\t\t\tenabledLinters = append(enabledLinters, lc)","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/linters.go#L75-L111","documentation":"The `linters` command's execute wraps errors from dbManager.GetEnabledLintersMap(), which computes the set of linters enabled by the loaded configuration. Unlike config errors, this fires after the config loaded successfully, when combining enabled-linter sets (e.g. conflicting presets or plugin loading issues) produces an inconsistency.","triggerScenarios":"Calling GetEnabledLintersMap during `golangci-lint linters` when the manager cannot resolve the enabled linters — typically duplicate/conflicting linter settings or a plugin builder failing to register a plugin linter.","commonSituations":"A config enabling the same linter twice (via presets and explicit enable), a Go plugin (.so) that cannot be built/loaded for the current golangci-lint/platform, or custom plugin modules whose module path is wrong.","solutions":["Read the wrapped cause after 'can't get enabled linters:' for the specific linter or plugin involved.","Remove duplicate entries where a linter is enabled both via a preset (e.g. presets: [style]) and linters.enable.","If using Go plugins, rebuild the .so with the exact same Go and golangci-lint versions, or migrate to the plugin module (GoModules) mechanism.","Disable plugins temporarily in the config to confirm they are the cause."],"exampleFix":"// before (.golangci.yml)\nlinters:\n  presets:\n    - style   # includes gocritic\n  enable:\n    - gocritic  # duplicate enable\n// after\nlinters:\n  presets:\n    - style","handlingStrategy":"try-catch","validationCode":"// pre-check config for duplicate linter enables (preset + explicit)\nlinters := cfg.Linters.Enable\nseen := map[string]bool{}\nfor _, l := range linters {\n    if seen[l] { return fmt.Errorf(\"linter %s enabled twice\", l) }\n    seen[l] = true\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Execute(); err != nil {\n    if strings.Contains(err.Error(), \"can't get enabled linters\") {\n        // inspect plugin/preset conflicts in config; disable plugins to isolate\n    }\n    os.Exit(1)\n}","preventionTips":["Avoid enabling a linter both via presets and explicitly.","Build Go plugins with the exact golangci-lint and Go versions, or use plugin modules.","Keep plugin .so binaries out of stale caches; rebuild on upgrades.","Test the linters command in CI to catch plugin incompatibilities early."],"tags":["go","linters","plugins","cli","golangci-lint"],"backgroundTag":"enabled-linters-resolution-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}