{"record":{"id":"1dab4ed8b878eceb","repo":"golangci/golangci-lint","slug":"can-t-parse-config-option-w","errorCode":null,"errorMessage":"can't parse --config option: %w","messagePattern":"can't parse --config option: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/base_loader.go","lineNumber":66,"sourceCode":"\t\treturn err\n\t}\n\n\terr = l.parseConfig()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc (l *BaseLoader) setConfigFile() error {\n\tconfigFile, err := l.evaluateOptions()\n\tif err != nil {\n\t\tif errors.Is(err, errConfigDisabled) {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(\"can't parse --config option: %w\", err)\n\t}\n\n\tif configFile != \"\" {\n\t\tl.viper.SetConfigFile(configFile)\n\n\t\t// Assume YAML if the file has no extension.\n\t\tif filepath.Ext(configFile) == \"\" {\n\t\t\tl.viper.SetConfigType(\"yaml\")\n\t\t}\n\t} else {\n\t\tl.setupConfigFileSearch()\n\t}\n\n\treturn nil\n}\n\nfunc (l *BaseLoader) evaluateOptions() (string, error) {\n\tif l.opts.NoConfig && l.opts.Config != \"\" {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/config/base_loader.go#L48-L84","documentation":"The config loader's evaluateOptions parses the --config flag (and related options) before loading YAML/etc. Any failure other than the sentinel errConfigDisabled (config explicitly disabled) is wrapped as \"can't parse --config option\", so an invalid --config value stops loading entirely.","triggerScenarios":"Invoking `golangci-lint run --config <path>` where path resolution/evaluation fails — e.g. empty/invalid flag value, unsupported expansion, or an error surfaced by the option evaluator.","commonSituations":"Typo'd --config path or flag value; passing a directory instead of a file; shell quoting dropping the value; combining --config with config-disabling flags incorrectly.","solutions":["Check the --config flag value for typos and that it points to an existing file, not a directory","Run `golangci-lint config path` / `--config` with an absolute path to rule out CWD issues","If you intended to skip config, use the dedicated option to disable config rather than a malformed --config","Inspect the wrapped %w error for the precise parse failure"],"exampleFix":"// before\ngolangci-lint run --config .golangci.yml.bak\n// after\ngolangci-lint run --config .golangci.yml","handlingStrategy":"validation","validationCode":"cfg := flag.String(\"config\", \"\", \"path\")\nif *cfg != \"\" {\n\tinfo, err := os.Stat(*cfg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"--config %s: %w\", *cfg, err)\n\t}\n\tif info.IsDir() {\n\t\treturn fmt.Errorf(\"--config %s is a directory\", *cfg)\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass absolute paths to --config in CI scripts","Verify the file exists before invoking golangci-lint","Don't confuse config path with directory; a directory is invalid","Check shell quoting so the flag value isn't empty"],"tags":["golangci-lint","config","cli"],"backgroundTag":"invalid-config-flag","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}