Files
hive/scripts/uv-discovery.ps1
Sundaram Kumar Jha 4a4f17ed40 fix quickstart guide for windows (#6264)
* fix(windows): verify uv is runnable before launch

* fix(windows): use validated uv path for kimi health check

* fix(windows): dedupe uv discovery and keep quickstart scoped

* chore: refresh uv lockfile
2026-03-15 15:19:15 +08:00

45 lines
1.4 KiB
PowerShell

function Get-WorkingUvInfo {
<#
.SYNOPSIS
Find a runnable uv executable, not just a PATH entry named "uv"
.OUTPUTS
Hashtable with Path and Version, or $null if no working uv is found
#>
# pyenv-win can expose a uv shim that exists on PATH but fails at runtime.
# Verify each candidate with `uv --version` before trusting it.
$candidates = @()
$commands = @(Get-Command uv -All -ErrorAction SilentlyContinue)
foreach ($cmd in $commands) {
if ($cmd.Source) {
$candidates += $cmd.Source
} elseif ($cmd.Definition) {
$candidates += $cmd.Definition
} elseif ($cmd.Name) {
$candidates += $cmd.Name
}
}
$defaultUvExe = Join-Path $env:USERPROFILE ".local\bin\uv.exe"
if (Test-Path $defaultUvExe) {
$candidates += $defaultUvExe
}
foreach ($candidate in ($candidates | Where-Object { $_ } | Select-Object -Unique)) {
try {
$versionOutput = & $candidate --version 2>$null
$version = ($versionOutput | Out-String).Trim()
if ($LASTEXITCODE -eq 0 -and -not [string]::IsNullOrWhiteSpace($version)) {
return @{
Path = $candidate
Version = $version
}
}
} catch {
# Try the next candidate.
}
}
return $null
}