{"record":{"id":"eac028022b6d326a","repo":"golangci/golangci-lint","slug":"get-base-path-w-eac028","errorCode":null,"errorMessage":"get base path: %w","messagePattern":"get base path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/goformat/runner.go","lineNumber":226,"sourceCode":"\treturn c.exitCode\n}\n\ntype RunnerOptions struct {\n\tbasePath  string\n\tpatterns  []*regexp.Regexp\n\tgenerated string\n\tdiff      bool\n\tcolors    bool\n\tstdin     bool\n\n\twarnUnused          bool\n\texcludedPathCounter map[*regexp.Regexp]int\n}\n\nfunc NewRunnerOptions(cfg *config.Config, diff, diffColored, stdin bool) (RunnerOptions, error) {\n\tbasePath, err := fsutils.GetBasePath(context.Background(), cfg.Run.RelativePathMode, cfg.GetConfigDir())\n\tif err != nil {\n\t\treturn RunnerOptions{}, fmt.Errorf(\"get base path: %w\", err)\n\t}\n\n\t// Required to be consistent with `RunnerOptions.MatchAnyPattern`.\n\tabsBasePath, err := filepath.Abs(basePath)\n\tif err != nil {\n\t\treturn RunnerOptions{}, err\n\t}\n\n\topts := RunnerOptions{\n\t\tbasePath:            absBasePath,\n\t\tgenerated:           cfg.Formatters.Exclusions.Generated,\n\t\tdiff:                diff || diffColored,\n\t\tcolors:              diffColored,\n\t\tstdin:               stdin,\n\t\texcludedPathCounter: make(map[*regexp.Regexp]int),\n\t\twarnUnused:          cfg.Formatters.Exclusions.WarnUnused,\n\t}\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/goformat/runner.go#L208-L244","documentation":"NewRunnerOptions resolves the base path used for formatter path matching via fsutils.GetBasePath, honoring run.relative-path-mode. If that resolution fails (bad mode value or filesystem error), the error is wrapped with this prefix and construction aborts before any formatting runs.","triggerScenarios":"Calling NewRunnerOptions with a config whose run.relative-path-mode is invalid, or whose config dir/working dir cannot be resolved (e.g. deleted cwd, symlink issues).","commonSituations":"Typo in `.golangci.yml` under run.relative-path-mode; running the binary from a deleted working directory; symlinked config directories that don't resolve.","solutions":["Set run.relative-path-mode to a valid value (e.g. `gomod`, `git-root`, `cfg`, or `cwd`) in .golangci.yml","Run golangci-lint from an existing directory (cd into the repo root)","Check that the config dir and symlinks resolve correctly (ls -l the paths)","Upgrade golangci-lint if your configured mode value should be supported"],"exampleFix":"# before\nrun:\n  relative-path-mode: relitive\n# after\nrun:\n  relative-path-mode: gomod","handlingStrategy":"validation","validationCode":"# validate config before running\nrun:\n  relative-path-mode: gomod   # one of: gomod, git-root, cfg, cwd","typeGuard":null,"tryCatchPattern":"// wrap construction and fail fast with config context\nro, err := NewRunnerOptions(cfg, diff, diffColored, stdin)\nif err != nil {\n    return fmt.Errorf(\"runner options invalid, check run.relative-path-mode: %w\", err)\n}","preventionTips":["Only use documented values for run.relative-path-mode","Run the linter from an existing directory","Keep config dir symlinks resolvable"],"tags":["golangci-lint","configuration","path-resolution"],"backgroundTag":"invalid-config-value","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}