{"record":{"id":"4809e10acf4e5a54","repo":"plandex-ai/plandex","slug":"error-getting-relative-path-s","errorCode":null,"errorMessage":"error getting relative path: %s","messagePattern":"error getting relative path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/fs/paths.go","lineNumber":76,"sourceCode":"\t\t\trepoRoot := strings.TrimSpace(string(output))\n\n\t\t\tcmd = exec.Command(\"git\", \"status\", \"--porcelain\")\n\t\t\tcmd.Dir = baseDir\n\t\t\tout, err := cmd.Output()\n\t\t\tif err != nil {\n\t\t\t\terrCh <- fmt.Errorf(\"error getting git status: %s\", err)\n\t\t\t}\n\n\t\t\tlines := strings.Split(string(out), \"\\n\")\n\n\t\t\tfor _, line := range lines {\n\t\t\t\tline = strings.TrimSpace(line)\n\t\t\t\tif strings.HasPrefix(line, \"D \") {\n\t\t\t\t\tpath := strings.TrimSpace(line[2:])\n\t\t\t\t\tabsPath := filepath.Join(repoRoot, path)\n\t\t\t\t\trelPath, err := filepath.Rel(currentDir, absPath)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\terrCh <- fmt.Errorf(\"error getting relative path: %s\", err)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tdeletedFiles[relPath] = true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\terrCh <- nil\n\t\t}()\n\n\t\t// combine `git ls-files` and `git ls-files --others --exclude-standard`\n\t\t// to get all files in the repo\n\n\t\tnumRoutines++\n\t\tgo func() {\n\t\t\t// get all tracked files in the repo\n\t\t\tcmd := exec.Command(\"git\", \"ls-files\")\n\t\t\tcmd.Dir = baseDir\n\t\t\tout, err := cmd.Output()","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/fs/paths.go#L58-L94","documentation":"When parsing `git status --porcelain` output for deleted files ('D ' lines), the code joins the repo root with the deleted path and calls filepath.Rel(currentDir, absPath) to express it relative to the current directory. This error is thrown when filepath.Rel cannot compute that relative path. filepath.Rel only fails when the two paths cannot be made relative to each other.","triggerScenarios":"currentDir and repoRoot are on different drives/volumes (Windows, e.g. C:\\ vs D:\\) so no relative path exists; one path is relative and the other absolute in a way filepath.Rel rejects; mixed path separators or a path with a volume name where the other has none.","commonSituations":"On Windows, running the CLI from a directory on a different drive than the repository root; passing currentDir with inconsistent formatting (UNC path vs drive letter); symlinked roots resolving to different volumes.","solutions":["Run the tool from a directory on the same drive/volume as the repository root.","Ensure currentDir (ProjectRoot) and baseDir are absolute, cleaned paths before calling GetPaths (filepath.Abs + filepath.Clean).","On Windows, avoid UNC paths (\\\\server\\share) mixed with drive-letter paths for the project.","If you control the call site, guard with filepath.IsAbs checks so both inputs are absolute on the same volume."],"exampleFix":"// before\ncurrentDir := \"D:\\work\" // repo on C:\npaths, err := fs.GetPaths(baseDir, currentDir)\n// after\ncurrentDir, _ := filepath.Abs(\"C:\\\\repo\\\\subdir\") // same volume as repoRoot\npaths, err := fs.GetPaths(baseDir, currentDir)","handlingStrategy":"validation","validationCode":"if filepath.VolumeName(currentDir) != filepath.VolumeName(repoRoot) {\n\treturn fmt.Errorf(\"currentDir and repo root must be on the same volume\")\n}\nif _, err := filepath.Rel(currentDir, repoRoot); err != nil {\n\treturn err\n}","typeGuard":"func sameVolume(a, b string) bool {\n\treturn filepath.IsAbs(a) && filepath.IsAbs(b) && filepath.VolumeName(a) == filepath.VolumeName(b)\n}","tryCatchPattern":"relPath, err := filepath.Rel(currentDir, absPath)\nif err != nil {\n\treturn fmt.Errorf(\"cannot make %s relative to %s: %w\", absPath, currentDir, err)\n}","preventionTips":["Keep the project and working directory on the same drive on Windows","Always pass absolute, cleaned paths (filepath.Abs + filepath.Clean) into the API","Avoid mixing UNC paths and mapped drive letters for the same location","Be careful with symlinks/junctions that cross volumes"],"tags":["go","path","windows"],"backgroundTag":"rel-path-computation-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}