fix(template): Always refresh PATH after git/7z check, not just after install
PATH refresh was inside the 'else' block (only during fresh install). If tools already exist from previous run, PATH not refreshed → validation fails. Move PATH refresh outside if/else for both Git and 7-Zip: - Already installed: skip download+install, but refresh PATH anyway - Fresh install: download+install, then refresh PATH Ensures validations can always resolve git/7z commands, even on retry runs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1027,13 +1027,13 @@ if (Test-Path $gitExe) {
|
|||||||
throw "Git installation failed (exit $($gitProc.ExitCode))."
|
throw "Git installation failed (exit $($gitProc.ExitCode))."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Git installer adds to PATH automatically; refresh
|
|
||||||
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' +
|
|
||||||
[System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
|
||||||
|
|
||||||
Write-Host "Git installed: $(git --version 2>&1)"
|
Write-Host "Git installed: $(git --version 2>&1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Refresh PATH whether freshly installed or already present
|
||||||
|
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' +
|
||||||
|
[System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
||||||
|
|
||||||
# Validation
|
# Validation
|
||||||
Assert-Step 'Git' 'git command resolvable' {
|
Assert-Step 'Git' 'git command resolvable' {
|
||||||
[bool](Get-Command git -ErrorAction SilentlyContinue)
|
[bool](Get-Command git -ErrorAction SilentlyContinue)
|
||||||
@@ -1076,13 +1076,13 @@ if (Test-Path $sevenZipExe) {
|
|||||||
throw "7-Zip installation failed (exit $($msiProc.ExitCode))."
|
throw "7-Zip installation failed (exit $($msiProc.ExitCode))."
|
||||||
}
|
}
|
||||||
|
|
||||||
# 7-Zip MSI adds to PATH; refresh session environment variable
|
|
||||||
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' +
|
|
||||||
[System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
|
||||||
|
|
||||||
Write-Host "7-Zip installed."
|
Write-Host "7-Zip installed."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Refresh PATH whether freshly installed or already present
|
||||||
|
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' +
|
||||||
|
[System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
||||||
|
|
||||||
# Validation
|
# Validation
|
||||||
Assert-Step '7-Zip' '7z.exe exists at expected path' {
|
Assert-Step '7-Zip' '7z.exe exists at expected path' {
|
||||||
Test-Path -Path $sevenZipExe -PathType Leaf
|
Test-Path -Path $sevenZipExe -PathType Leaf
|
||||||
|
|||||||
Reference in New Issue
Block a user