{"record":{"id":"5162a2f16663e25a","repo":"golangci/golangci-lint","slug":"can-t-get-working-directory-w","errorCode":null,"errorMessage":"can't get working directory: %w","messagePattern":"can't get working directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fsutils/fsutils.go","lineNumber":75,"sourceCode":"\tr, ok := evalSymlinkCache.Load(path)\n\tif ok {\n\t\ter := r.(evalSymlinkRes)\n\t\treturn er.path, er.err\n\t}\n\n\tvar er evalSymlinkRes\n\ter.path, er.err = evalSymlinks(path)\n\tevalSymlinkCache.Store(path, er)\n\n\treturn er.path, er.err\n}\n\nfunc ShortestRelPath(path, wd string) (string, error) {\n\tif wd == \"\" { // get it if user don't have cached working dir\n\t\tvar err error\n\t\twd, err = Getwd()\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"can't get working directory: %w\", err)\n\t\t}\n\t}\n\n\tevaluatedPath, err := EvalSymlinks(path)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"can't eval symlinks for path %s: %w\", path, err)\n\t}\n\tpath = evaluatedPath\n\n\t// make path absolute and then relative to be able to fix this case:\n\t// we are in `/test` dir, we want to normalize `../test`, and have file `file.go` in this dir;\n\t// it must have normalized path `file.go`, not `../test/file.go`,\n\tvar absPath string\n\tif filepath.IsAbs(path) {\n\t\tabsPath = path\n\t} else {\n\t\tabsPath = filepath.Join(wd, path)\n\t}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/fsutils/fsutils.go#L57-L93","documentation":"Wrapping error in ShortestRelPath: when no working directory is supplied, Getwd() is called and its failure (os-level failure or unresolvable symlinks on the wd) is re-wrapped with this prefix. The relative-path computation cannot proceed without a wd.","triggerScenarios":"Thrown at pkg/fsutils/fsutils.go:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the process working directory is valid","Pass an explicit working directory where the API allows","Resolve broken symlinks on the working directory"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}