golangci/golangci-lint · error
can't get enabled linters: %w
Error message
can't get enabled linters: %w
What it means
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.
Source
Thrown at pkg/commands/linters.go:93
if err != nil {
return fmt.Errorf("can't load config: %w", err)
}
dbManager, err := lintersdb.NewManager(c.log.Child(logutils.DebugKeyLintersDB), c.cfg,
lintersdb.NewLinterBuilder(), lintersdb.NewPluginModuleBuilder(c.log), lintersdb.NewPluginGoBuilder(c.log))
if err != nil {
return err
}
c.dbManager = dbManager
return nil
}
func (c *lintersCommand) execute(_ *cobra.Command, _ []string) error {
enabledLintersMap, err := c.dbManager.GetEnabledLintersMap()
if err != nil {
return fmt.Errorf("can't get enabled linters: %w", err)
}
var enabledLinters []*linter.Config
var disabledLinters []*linter.Config
for _, lc := range c.dbManager.GetAllSupportedLinterConfigs() {
if lc.Internal {
continue
}
if goformatters.IsFormatter(lc.Name()) {
continue
}
if enabledLintersMap[lc.Name()] == nil {
disabledLinters = append(disabledLinters, lc)
} else {
enabledLinters = append(enabledLinters, lc)View on GitHub (pinned to ed7a235d2d)
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.
Example fix
// before (.golangci.yml)
linters:
presets:
- style # includes gocritic
enable:
- gocritic # duplicate enable
// after
linters:
presets:
- style Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check config for duplicate linter enables (preset + explicit)
linters := cfg.Linters.Enable
seen := map[string]bool{}
for _, l := range linters {
if seen[l] { return fmt.Errorf("linter %s enabled twice", l) }
seen[l] = true
} Try / catch
if err := cmd.Execute(); err != nil {
if strings.Contains(err.Error(), "can't get enabled linters") {
// inspect plugin/preset conflicts in config; disable plugins to isolate
}
os.Exit(1)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- can't load config: %w
- can't combine option --config and --no-config
- update plugin file: %w
- hash plugin directory: %w
- saving configuration file: %w
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/b6da589896a27a69.
Report an issue: GitHub.