{"record":{"id":"c29f58952a498e5b","repo":"golangci/golangci-lint","slug":"can-t-get-relative-path-for-path-s-and-root-s","errorCode":null,"errorMessage":"can't get relative path for path %s and root %s: %w","messagePattern":"can't get relative path for path (.+?) and root (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fsutils/fsutils.go","lineNumber":97,"sourceCode":"\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}\n\n\trelPath, err := filepath.Rel(wd, absPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"can't get relative path for path %s and root %s: %w\",\n\t\t\tabsPath, wd, err)\n\t}\n\n\treturn relPath, nil\n}\n","sourceCodeStart":79,"sourceCodeEnd":103,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/fsutils/fsutils.go#L79-L103","documentation":"Wrapping error in ShortestRelPath: filepath.Rel(wd, absPath) failed after resolving the path against the working directory. Rel rarely fails — typically the wd could not be made relative to the target (e.g. mismatched roots on Windows or a wd that no longer exists).","triggerScenarios":"Thrown at pkg/fsutils/fsutils.go:97 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the working directory and target path share a valid root","Check that the wd exists and is a directory","Inspect the wrapped error for the exact Rel failure reason"],"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"}