{"record":{"id":"8b49403903f5d227","repo":"golangci/golangci-lint","slug":"can-t-get-config-directory","errorCode":null,"errorMessage":"can't get config directory","messagePattern":"can't get config directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/base_loader.go","lineNumber":210,"sourceCode":"\t\treturn nil\n\t}\n\n\tif usedConfigFile == os.Stdin.Name() {\n\t\tusedConfigFile = \"\"\n\t\tl.log.Infof(\"Reading config file stdin\")\n\t} else {\n\t\tvar err error\n\t\tusedConfigFile, err = fsutils.ShortestRelPath(usedConfigFile, \"\")\n\t\tif err != nil {\n\t\t\tl.log.Warnf(\"Can't pretty print config file path: %v\", err)\n\t\t}\n\n\t\tl.log.Infof(\"Used config file %s\", usedConfigFile)\n\t}\n\n\tusedConfigDir, err := filepath.Abs(filepath.Dir(usedConfigFile))\n\tif err != nil {\n\t\treturn errors.New(\"can't get config directory\")\n\t}\n\n\tl.cfg.SetConfigDir(usedConfigDir)\n\n\treturn nil\n}\n\nfunc customDecoderHook() viper.DecoderConfigOption {\n\treturn viper.DecodeHook(DecodeHookFunc())\n}\n\nfunc DecodeHookFunc() mapstructure.DecodeHookFunc {\n\treturn mapstructure.ComposeDecodeHookFunc(\n\t\t// Default hooks (https://github.com/spf13/viper/blob/518241257478c557633ab36e474dfcaeb9a3c623/viper.go#L135-L138).\n\t\tmapstructure.StringToTimeDurationHookFunc(),\n\t\tmapstructure.StringToSliceHookFunc(\",\"),\n\n\t\t// Needed for forbidigo, and output.formats.","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/config/base_loader.go#L192-L228","documentation":"parseConfig computes the directory of the resolved config file with filepath.Abs(filepath.Dir(usedConfigFile)) so relative paths inside the config resolve against the config's location. If converting that directory to an absolute path fails, this error is returned and config parsing aborts.","triggerScenarios":"filepath.Abs failing for the directory of the used config file — typically a path resolution error on an unusual/invalid working directory or file path.","commonSituations":"Running with a deleted or inaccessible current working directory; exotic filesystem setups where filepath.Abs cannot resolve the relative dir.","solutions":["Run golangci-lint from a valid, existing working directory.","Pass a fully absolute --config path so its directory resolves cleanly.","Verify the config file actually exists at the resolved location before invoking the loader."],"exampleFix":"// before\ncd /tmp/deleted-dir && golangci-lint run --config ../.golangci.yml\n\n// after\ncd /path/to/project && golangci-lint run --config /path/to/project/.golangci.yml","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nconst dir = path.dirname(path.resolve(configPath));\nif (!fs.existsSync(dir)) throw new Error(`Config directory does not resolve: ${dir}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the linter from an existing project directory.","Prefer absolute --config paths to avoid cwd-dependent resolution.","Don't delete the cwd (or run from it) while tools are executing."],"tags":["filesystem","configuration","path-resolution"],"backgroundTag":"path-resolution-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}