fix(windows): skip install if Tailscale already present (avoid MSI 1603)

A prior .exe(NSIS) install leaves Tailscale on disk but not on PATH; the MSI
then fails with error 1603 trying to install over it. Now detect the existing
binary at C:\Program Files\Tailscale\tailscale.exe and skip installation, and
treat a nonzero msiexec exit as success when the binary is already present.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
PharmQ Admin
2026-05-31 01:17:07 +00:00
parent 32118e7c6c
commit 99fd031d5a
2 changed files with 43 additions and 16 deletions

View File

@@ -106,15 +106,22 @@ function Test-Requirements {
function Install-Tailscale {
Write-Status "Tailscale 클라이언트 확인 중..."
# 기존 설치 확인
# 기존 설치 확인 (PATH 또는 기본 설치 경로).
# 중요: 이전 실행에서 .exe(NSIS)로 이미 설치됐는데 PATH엔 안 잡혀 있을 수
# 있다. 그 위에 MSI로 덮어쓰면 오류 1603으로 실패한다. 그래서 바이너리가
# 이미 있으면 설치를 통째로 건너뛰고 이번 세션 PATH에만 추가한다.
$tailscaleExe = "C:\Program Files\Tailscale\tailscale.exe"
$tailscalePath = Get-Command "tailscale" -ErrorAction SilentlyContinue
if ($tailscalePath) {
$version = & tailscale version 2>$null | Select-Object -First 1
Write-Info "Tailscale이 이미 설치되어 있습니다."
Write-Info "현재 버전: $version"
if ($tailscalePath -or (Test-Path $tailscaleExe)) {
Write-Info "Tailscale이 이미 설치되어 있습니다. 설치를 건너뜁니다."
if (-not $tailscalePath -and ($env:Path -notlike "*Tailscale*")) {
$env:Path = "$env:Path;C:\Program Files\Tailscale"
}
$version = & $tailscaleExe version 2>$null | Select-Object -First 1
if ($version) { Write-Info "현재 버전: $version" }
return
}
Write-Info "Windows용 Tailscale 설치 중..."
# 공식 stable 채널의 'latest' MSI를 msiexec /quiet 로 설치한다.
@@ -138,14 +145,20 @@ function Install-Tailscale {
-Wait -PassThru
# 0 = 성공, 3010 = 성공(재부팅 필요)
if ($proc.ExitCode -ne 0 -and $proc.ExitCode -ne 3010) {
throw "msiexec 종료 코드 $($proc.ExitCode). 로그: $logPath"
# 1603 등은 충돌하는/불완전한 기존 설치가 있을 때 자주 난다.
# 그래도 바이너리가 있으면 설치된 것으로 보고 계속 진행하고,
# 없으면 로그 경로와 함께 실패를 알린다.
if (Test-Path $tailscaleExe) {
Write-Warning "msiexec 종료 코드 $($proc.ExitCode) 이지만 Tailscale이 이미 존재합니다. 계속 진행합니다."
} else {
throw "msiexec 종료 코드 $($proc.ExitCode). 로그: $logPath"
}
}
# PATH 환경변수 새로고침
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# 이번 세션 PATH에 설치 경로 보장
$tailscaleExe = "C:\Program Files\Tailscale\tailscale.exe"
if (Test-Path $tailscaleExe) {
$currentPath = [Environment]::GetEnvironmentVariable("Path", "Machine")
if ($currentPath -notlike "*Tailscale*") {