{"record":{"id":"0c4180a76e8f9fe4","repo":"golangci/golangci-lint","slug":"get-wd-w","errorCode":null,"errorMessage":"get wd: %w","messagePattern":"get wd: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fsutils/basepath.go","lineNumber":59,"sourceCode":"\t\tgoMod, err := goenv.GetOne(ctx, goenv.GOMOD)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"get go.mod path: %w\", err)\n\t\t}\n\n\t\treturn filepath.Dir(goMod), nil\n\n\tcase RelativePathModeGitRoot:\n\t\troot, err := gitRoot(ctx)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"get git root: %w\", err)\n\t\t}\n\n\t\treturn root, nil\n\n\tcase RelativePathModeWd:\n\t\twd, err := Getwd()\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"get wd: %w\", err)\n\t\t}\n\n\t\treturn wd, nil\n\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unknown relative path mode: %s\", mode)\n\t}\n}\n\nfunc gitRoot(ctx context.Context) (string, error) {\n\tcmd := exec.CommandContext(ctx, \"git\", \"rev-parse\", \"--show-toplevel\")\n\tout, err := cmd.Output()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(bytes.TrimSpace(out)), nil\n}","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/fsutils/basepath.go#L41-L77","documentation":"GetBasePath returns this wrapped error when the relative path mode is RelativePathModeWd and Getwd() fails to determine the current working directory. The OS-level cause is preserved via %w. This is rare and usually means the process's working directory no longer exists or is inaccessible.","triggerScenarios":"Calling golangci-lint (with run.relative-path-mode: wd, or default flows calling GetBasePath) after the current directory has been deleted, or when permission/OS errors prevent os.Getwd from resolving it.","commonSituations":"CI jobs that delete the workspace while the linter runs; launching the process from a removed temp dir; broken symlinked working directories; permission problems on containers.","solutions":["Re-create or cd back into a valid directory before running golangci-lint","Check permissions on the working directory path (read/execute bits)","Inspect the wrapped %w error for the exact OS cause (e.g. ENOENT, EACCES) and fix accordingly"],"exampleFix":"// shell before: run from a deleted dir\nrm -rf /tmp/work && cd /tmp/work && golangci-lint run\n// after\ncd /existing/project && golangci-lint run","handlingStrategy":"try-catch","validationCode":"if wd, err := os.Getwd(); err != nil {\n  return fmt.Errorf(\"working directory unusable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"basePath, err := fsutils.GetBasePath(ctx, mode)\nif err != nil {\n  if wd, wdErr := os.Getwd(); wdErr != nil {\n    log.Fatalf(\"cwd unavailable: %v\", wdErr) // re-enter a valid directory\n  }\n  return err\n}","preventionTips":["Do not delete the workspace while the linter process runs","cd into an existing project directory before invoking the linter","Check directory permissions in containers","Avoid launching from temp dirs that get cleaned up"],"tags":["filesystem","os","path-resolution"],"backgroundTag":"working-directory-unavailable","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}