Skip to content

Commit 56ef341

Browse files
Jonas Lindströmclaude
andcommitted
install.ps1: prepend to user PATH, fix reinstall over existing kit.exe
- Move-Item -Force failed when kit.exe already existed; use Copy-Item - clear message when kit.exe is locked (running kit / virus scanner) - put install dir first in user PATH so old copies don't shadow it Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent c9b6a2e commit 56ef341

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

‎install.ps1‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,34 @@ try {
3737

3838
New-Item -ItemType Directory -Path $installDir -Force | Out-Null
3939
$target = Join-Path $installDir 'kit.exe'
40-
Move-Item (Join-Path $tmp 'kit.exe') $target -Force
40+
try {
41+
# Copy statt Move: Move-Item -Force scheitert, wenn das Ziel existiert
42+
Copy-Item (Join-Path $tmp 'kit.exe') $target -Force
43+
}
44+
catch [System.IO.IOException] {
45+
throw "$target ist gesperrt — laufendes kit schliessen (oder kurz warten, falls der Virenscanner prüft) und nochmals starten."
46+
}
4147
Write-Host "Installiert: $target"
4248
}
4349
finally {
4450
Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue
4551
}
4652

47-
# Zielordner in den Benutzer-PATH
53+
# Zielordner an den Anfang des Benutzer-PATH, damit er vor alten kit-Kopien liegt
4854
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
49-
$entries = if ($userPath) { $userPath -split ';' } else { @() }
50-
if ($entries -notcontains $installDir) {
51-
[Environment]::SetEnvironmentVariable('Path', (($entries + $installDir) -join ';').Trim(';'), 'User')
52-
Write-Host "$installDir wurde zum Benutzer-PATH hinzugefügt (neues Terminal öffnen)."
55+
$entries = @(if ($userPath) { $userPath -split ';' | Where-Object { $_ } })
56+
if ($entries[0] -ne $installDir) {
57+
$rest = @($entries | Where-Object { $_ -ne $installDir })
58+
[Environment]::SetEnvironmentVariable('Path', ((@($installDir) + $rest) -join ';'), 'User')
59+
Write-Host "$installDir steht jetzt vorne im Benutzer-PATH (neues Terminal öffnen)."
5360
}
54-
if (($env:Path -split ';') -notcontains $installDir) { $env:Path = "$env:Path;$installDir" }
61+
$env:Path = "$installDir;" + (($env:Path -split ';' | Where-Object { $_ -and $_ -ne $installDir }) -join ';')
5562

5663
# Andere kit.exe, die vorher im PATH liegen (z. B. alte pipx-Installation)?
5764
$others = Get-Command kit -All -CommandType Application -ErrorAction SilentlyContinue |
5865
Where-Object { $_.Source -ne $target }
5966
foreach ($other in $others) {
60-
Write-Warning "Weitere kit-Installation gefunden: $($other.Source) — entfernen, damit nicht die alte startet."
67+
Write-Warning "Weitere kit-Installation gefunden: $($other.Source) — entfernen (pipx: 'pipx uninstall kit')."
6168
}
6269

6370
$codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $HOME '.codex' }

0 commit comments

Comments
 (0)