fix: resolve symlinks in Instance cache to prevent duplicate contexts (#16651)

Co-authored-by: LukeParkerDev <10430890+Hona@users.noreply.github.com>
This commit is contained in:
John Mylchreest
2026-03-11 23:26:54 +00:00
committed by GitHub
parent 34fa5de9c5
commit f1c3a44190
2 changed files with 61 additions and 1 deletions

View File

@@ -114,8 +114,16 @@ export namespace Filesystem {
}
// We cannot rely on path.resolve() here because git.exe may come from Git Bash, Cygwin, or MSYS2, so we need to translate these paths at the boundary.
// Also resolves symlinks so that callers using the result as a cache key
// always get the same canonical path for a given physical directory.
export function resolve(p: string): string {
return normalizePath(pathResolve(windowsPath(p)))
const resolved = pathResolve(windowsPath(p))
try {
return normalizePath(realpathSync(resolved))
} catch (e) {
if (isEnoent(e)) return normalizePath(resolved)
throw e
}
}
export function windowsPath(p: string): string {