check appdata dir for uv binary on windows

(cherry picked from commit ea45127f5088e1aad3eb0f72dcd8fcca9577727c)

IJ-MR-153730

GitOrigin-RevId: e828e88ecb268ea37444337d8b0efff3eb36700c
This commit is contained in:
Aleksandr Sorotskii
2025-01-24 13:03:20 +01:00
committed by intellij-monorepo-bot
parent 0d206b1e3e
commit b3bbc880e5

View File

@@ -67,9 +67,22 @@ fun detectUvExecutable(): Path? {
else -> "uv"
}
return PathEnvironmentVariableUtil.findInPath(name)?.toPath() ?: SystemProperties.getUserHome().let { homePath ->
Path.of(homePath, ".local", "bin", name).takeIf { it.exists() } ?: Path.of(homePath, ".cargo", "bin", name).takeIf { it.exists() }
val binary = PathEnvironmentVariableUtil.findInPath(name)?.toPath()
if (binary != null) {
return binary
}
val userHome = SystemProperties.getUserHome()
val appData = if (SystemInfo.isWindows) System.getenv("APPDATA") else null
val paths = mutableListOf<Path>().apply {
add(Path.of(userHome, ".local", "bin", name))
add(Path.of(userHome, ".local", "bin", name))
if (appData != null) {
add(Path.of(appData, "Python", "Scripts", name))
}
}
return paths.firstOrNull { it.exists() }
}
fun getUvExecutable(): Path? {