golangci/golangci-lint · error
configuration version is already set: %s
Error message
configuration version is already set: %s
What it means
The migrate command refuses to run when the loaded configuration already has a version set, i.e. it is not a plain v1 config. Migration targets unversioned/v1 configs; a config that already declares `version: "2"` (or similar) is not something migrate can convert. This check happens in `preRunE` after format validation.
Source
Thrown at pkg/commands/migrate.go:142
}
c.log.Infof("Migration done: %s", dstPath)
callForAction(c.cmd)
return nil
}
func (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error {
switch strings.ToLower(c.opts.format) {
case "", "yml", "yaml", "toml", "json":
// Valid format.
default:
return fmt.Errorf("unsupported format: %s", c.opts.format)
}
if c.cfg.Version != "" {
return fmt.Errorf("configuration version is already set: %s", c.cfg.Version)
}
if c.opts.skipValidation {
return nil
}
usedConfigFile := c.viper.ConfigFileUsed()
if usedConfigFile == "" {
c.log.Warnf("No config file detected")
os.Exit(exitcodes.NoConfigFileDetected)
}
c.log.Infof("Validating v1 configuration file: %s", usedConfigFile)
err := validateConfiguration(jsonsch.V1Schema, usedConfigFile)
if err != nil {
var v *jsonschema.ValidationError
if !errors.As(err, &v) {View on GitHub (pinned to ed7a235d2d)
Solutions
- Don't migrate — the config is already versioned; use it as-is.
- If you truly want a fresh migration, remove the `version:` line from the config file first (only if it is a v1-shaped config).
- Restore the original v1 config from version control before running migrate.
Example fix
# before (.golangci.yml)
version: "2"
linters:
enable: [govet]
# after (original v1 config)
linters:
enable:
- govet Defensive patterns
Strategy: validation
Validate before calling
// check the config for a version key before migrating
data, _ := os.ReadFile(".golangci.yml")
if strings.Contains(string(data), "version:") {
return errors.New("config already declares a version; migration not needed")
} Prevention
- Run migrate only once per config; version it in git afterward.
- Check the config head for `version:` before re-running migrate.
- Keep already-migrated v2 configs out of migrate workflows.
- Restore the original v1 config from VCS if you need to re-migrate.
When it happens
Trigger: Running `golangci-lint migrate` against a config file that already contains a `version:` key (e.g. it was already migrated to v2), so `c.cfg.Version` is non-empty.
Common situations: Running migrate twice on the same repo; pointing migrate at a `.golangci.yml` already migrated by a teammate; a config template that ships with `version: "2"` already set.
Related errors
- can't load config: %w
- saving configuration file: %w
- unsupported format: %s
- can't load config: %w
- hash plugin directory: %w
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/62f5eafc1419d149.
Report an issue: GitHub.