golangci/golangci-lint · error
get base path: %w
Error message
get base path: %w
What it means
Loader.Load computes the base path via fsutils.GetBasePath using run.relative-path-mode and the config directory; any failure is wrapped as 'get base path: %w'. The base path is needed to resolve relative paths in the config against the correct root.
Source
Thrown at pkg/config/loader.go:114
if opts.CheckDeprecation {
err = l.handleDeprecation()
if err != nil {
return err
}
l.handleFormatterDeprecations()
}
l.handleGoVersion()
err = goutil.CheckGoVersion(l.cfg.Run.Go)
if err != nil {
return err
}
l.cfg.basePath, err = fsutils.GetBasePath(context.Background(), l.cfg.Run.RelativePathMode, l.cfg.cfgDir)
if err != nil {
return fmt.Errorf("get base path: %w", err)
}
err = l.handleEnableOnlyOption()
if err != nil {
return err
}
if opts.Validation {
err = l.cfg.Validate()
if err != nil {
return err
}
}
return nil
}
// Hack to append values from StringSlice flags.View on GitHub (pinned to ed7a235d2d)
Solutions
- Read the wrapped inner error for the root cause
- Set run.relative-path-mode to a valid value (e.g. cfg, gomod, gitroot, subdir) or remove it to use the default
- Ensure the config directory and working directory exist and are accessible
Example fix
# before run: relative-path-mode: bogus-mode # after run: relative-path-mode: gomod
Defensive patterns
Strategy: validation
Validate before calling
switch cfg.Run.RelativePathMode {
case "", "cfg", "gomod", "gitroot", "subdir", "wd":
// ok
default:
return fmt.Errorf("unsupported relative-path-mode: %s", cfg.Run.RelativePathMode)
} Try / catch
if err := loader.Load(ctx); err != nil {
if strings.HasPrefix(err.Error(), "get base path:") {
log.Fatalf("base path resolution failed: %v", err)
}
} Prevention
- Use only documented relative-path-mode values
- Ensure cwd and config dir exist before launching (esp. in containers)
- Prefer the default mode unless you need explicit path resolution
When it happens
Trigger: GetBasePath failing due to an invalid run.relative-path-mode value, an inaccessible cfgDir, or filesystem errors while resolving the working directory (e.g. deleted cwd).
Common situations: Setting run.relative-path-mode to an unsupported value; running the binary from a deleted working directory; container/CI environments where the config dir doesn't exist.
Related errors
- can't write heap profile: %w
- can't open file %s: %w
- error getting working directory: %w
- Can't get working dir: %s
- the configuration contains invalid elements
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/250f6825d28d1b39.
Report an issue: GitHub.