golangci/golangci-lint · error
failed to get enabled linters: %w
Error message
failed to get enabled linters: %w
What it means
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".
Source
Thrown at pkg/lint/runner.go:52
}
func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env,
lineCache *fsutils.LineCache, fileCache *fsutils.FileCache,
dbManager *lintersdb.Manager, lintCtx *linter.Context,
) (*Runner, error) {
pathRelativity, err := processors.NewPathRelativity(log, cfg.GetBasePath())
if err != nil {
return nil, fmt.Errorf("error creating path relativity processor: %w", err)
}
exclusionPaths, err := processors.NewExclusionPaths(log, &cfg.Linters.Exclusions)
if err != nil {
return nil, err
}
enabledLinters, err := dbManager.GetEnabledLintersMap()
if err != nil {
return nil, fmt.Errorf("failed to get enabled linters: %w", err)
}
var enabledFormatters []string
for name := range maps.Keys(enabledLinters) {
if goformatters.IsFormatter(name) {
enabledFormatters = append(enabledFormatters, name)
}
}
switch len(enabledLinters) {
case 0:
return nil, errors.New("no linters enabled")
case 1:
if _, ok := enabledLinters["typecheck"]; ok {
return nil, errors.New("no linters enabled")
}
}
View on GitHub (pinned to ed7a235d2d)
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
Example fix
// before (.golangci.yml)
linters:
enable:
- gofmt
- gofumpt # conflicting formatters
// after
linters:
enable:
- gofumpt Defensive patterns
Strategy: validation
Validate before calling
// Validate the enabled-linter set before running: // golangci-lint cache status // golangci-lint config verify // golangci-lint linters | grep -E '<enabled names>' # confirm each resolves and isn't exclusive
Try / catch
enabled, err := dbManager.GetEnabledLintersMap()
if err != nil {
return fmt.Errorf("failed to get enabled linters: %w", err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unknown linters: '%v', run 'golangci-lint help linters' to s
- can't combine option --config and --no-config
- can't get enabled formatters: %w
- can't get enabled linters: %w
- failed to set analyzer setting %q with value %q: %w
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/9070ec4b19fd104a.
Report an issue: GitHub.