diff --git a/python/src/com/jetbrains/python/sdk/uv/impl/UvCli.kt b/python/src/com/jetbrains/python/sdk/uv/impl/UvCli.kt index 71676b168246..e0b4c25b451d 100644 --- a/python/src/com/jetbrains/python/sdk/uv/impl/UvCli.kt +++ b/python/src/com/jetbrains/python/sdk/uv/impl/UvCli.kt @@ -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().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? {