Skip to content

Commit e7a4891

Browse files
authored
Merge pull request #68 from philnach/fix/windows-stale-path
windows: refresh PATH and assert required tools in scenario run scripts
2 parents 3cb3324 + 620c136 commit e7a4891

19 files changed

Lines changed: 142 additions & 10 deletions

File tree

scenarios/windows/fast_api/fast_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class FastApi(core.app_scenario.Scenario):
1515

1616
module = __module__.split('.')[-1]
17-
prep_version = "4"
17+
prep_version = "5"
1818
resources = module + "_resources"
1919

2020

scenarios/windows/fast_api/fast_api_resources/fast_api_run.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,19 @@ Set-OptimizedPathOrder
281281
# PATH is now optimized: pyenv first (from User PATH), then system dirs (from Machine PATH)
282282
# Windows Store Python is at the end with lowest priority
283283

284+
# Verify required commands are findable on PATH after Set-OptimizedPathOrder.
285+
# Fail fast with a clear diagnostic instead of a chain of "term not recognized" errors.
286+
foreach ($cmd in @('pyenv', 'python')) {
287+
$resolved = Get-Command $cmd -ErrorAction SilentlyContinue
288+
if (-not $resolved) {
289+
" ERROR - Required command '$cmd' not found on PATH after PATH optimization." | log
290+
" ERROR - Prep may not have completed, or the RPC service has a stale PATH." | log
291+
" ERROR - PATH: $env:Path" | log
292+
Exit 1
293+
}
294+
"Found ${cmd}: $($resolved.Source)" | log
295+
}
296+
284297
Set-Location "$scriptDrive\FastAPI"
285298

286299
"Setting Python global version to $pythonVersion..." | log

scenarios/windows/foundrylocal/foundrylocal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class Foundrylocal(core.app_scenario.Scenario):
1515

1616
module = __module__.split('.')[-1]
17-
prep_version = "6"
17+
prep_version = "7"
1818
resources = module + "_resources"
1919

2020

scenarios/windows/foundrylocal/foundrylocal_resources/foundrylocal_run.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@ Write-RunPhaseMarker "phase.run_prep.start"
109109
# Refresh PATH to ensure foundry is available
110110
$Env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
111111

112+
# Verify required commands are findable on PATH after refresh.
113+
# Fail fast with a clear diagnostic instead of a chain of "term not recognized" errors.
114+
foreach ($cmd in @('foundry')) {
115+
$resolved = Get-Command $cmd -ErrorAction SilentlyContinue
116+
if (-not $resolved) {
117+
" ERROR - Required command '$cmd' not found on PATH after refresh." | log
118+
" ERROR - Prep may not have completed, or the RPC service has a stale PATH." | log
119+
" ERROR - PATH: $env:Path" | log
120+
Exit 1
121+
}
122+
"Found ${cmd}: $($resolved.Source)" | log
123+
}
124+
112125
# Output directory for results
113126
$outputDir = "$scriptDrive\hobl_data"
114127
if (-not (Test-Path $outputDir)) {

scenarios/windows/llvm/llvm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class Llvm(scenarios.app_scenario.Scenario):
1515

1616
module = __module__.split('.')[-1]
17-
prep_version = "7"
17+
prep_version = "8"
1818
resources = module + "_resources"
1919

2020

scenarios/windows/llvm/llvm_resources/llvm_run.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ Write-RunPhaseMarker "phase.run_prep.start"
132132

133133
$Env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
134134

135+
# Verify required commands are findable on PATH after refresh.
136+
# Fail fast with a clear diagnostic instead of a chain of "term not recognized" errors.
137+
foreach ($cmd in @('ninja')) {
138+
$resolved = Get-Command $cmd -ErrorAction SilentlyContinue
139+
if (-not $resolved) {
140+
" ERROR - Required command '$cmd' not found on PATH after refresh." | log
141+
" ERROR - Prep may not have completed, or the RPC service has a stale PATH." | log
142+
" ERROR - PATH: $env:Path" | log
143+
Exit 1
144+
}
145+
"Found ${cmd}: $($resolved.Source)" | log
146+
}
147+
135148
# --- Initialize Visual Studio Developer Command environment ---
136149
# VsDevCmd.bat sets up LIB, INCLUDE, and PATH so that MSVC libraries and headers
137150
# are discoverable during the build (e.g., ATL/MFC, Windows SDK, UCRT).

scenarios/windows/net_aspire/net_aspire.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class NetAspire(core.app_scenario.Scenario):
1515

1616
module = __module__.split('.')[-1]
17-
prep_version = "8"
17+
prep_version = "9"
1818
resources = module + "_resources"
1919

2020

scenarios/windows/net_aspire/net_aspire_resources/net_aspire_run.ps1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ function Write-RunPhaseMarker {
5151
# Configuration
5252
$scriptDrive = Split-Path -Qualifier $PSScriptRoot
5353

54+
# Refresh PATH from Machine+User environment so dotnet (installed via winget during prep)
55+
# is visible to this session. The HOBL RPC service started before prep ran, so the inherited
56+
# PATH is stale and does not include C:\Program Files\dotnet without this refresh.
57+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
58+
59+
# Fallback: ensure the default dotnet install directory is on PATH even if the env var
60+
# was not updated (e.g. dotnet installed by a non-winget installer that did not update PATH).
61+
$dotnetDir = "C:\Program Files\dotnet"
62+
if ((Test-Path "$dotnetDir\dotnet.exe") -and (";$env:Path;" -notlike "*;$dotnetDir;*")) {
63+
$env:Path = "$dotnetDir;$env:Path"
64+
}
65+
5466
if (-not (Test-Path "$scriptDrive\hobl_data")) {
5567
Write-Host " ERROR - Required directory not found: $scriptDrive\hobl_data" -ForegroundColor Red
5668
Exit 1
@@ -125,7 +137,13 @@ if (-not (Test-Path ".\Aspire.slnx")) {
125137
# that doesn't inherit env vars set during prep.
126138
$env:DOTNET_INSTALL_DIR = "C:\Program Files\dotnet"
127139
"-- DOTNET_INSTALL_DIR set to '$($env:DOTNET_INSTALL_DIR)' (prevents Arcade SDK from downloading x64 runtimes)" | log
128-
"-- dotnet on PATH: $(Get-Command dotnet -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source)" | log
140+
$dotnetCmd = Get-Command dotnet -ErrorAction SilentlyContinue
141+
if (-not $dotnetCmd) {
142+
" ERROR - dotnet not found on PATH. Prep may not have completed, or PATH was not refreshed." | log
143+
" ERROR - PATH: $env:Path" | log
144+
Exit 1
145+
}
146+
"-- dotnet on PATH: $($dotnetCmd.Source)" | log
129147
"-- Active SDK version: $(dotnet --version 2>&1)" | log
130148
"-- All installed SDKs:" | log
131149
dotnet --list-sdks 2>&1 | ForEach-Object { " $_" | log }

scenarios/windows/net_aspire/net_aspire_resources/net_aspire_teardown.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ if (-not $logFile) { $logFile = "$scriptDrive\hobl_data\net_aspire_teardown.log"
1010

1111
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
1212

13+
# Refresh PATH from Machine+User environment so dotnet (installed via winget during prep)
14+
# is visible to this session. The HOBL RPC service started before prep ran, so the inherited
15+
# PATH is stale and does not include C:\Program Files\dotnet without this refresh.
16+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
17+
$dotnetDir = "C:\Program Files\dotnet"
18+
if ((Test-Path "$dotnetDir\dotnet.exe") -and (";$env:Path;" -notlike "*;$dotnetDir;*")) {
19+
$env:Path = "$dotnetDir;$env:Path"
20+
}
21+
1322
# Determine processor architecture for log file naming
1423
$osInfo = Get-CimInstance Win32_OperatingSystem
1524
$arch = $osInfo.OSArchitecture

scenarios/windows/nodejs/nodejs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class Nodejs(core.app_scenario.Scenario):
1515

1616
module = __module__.split('.')[-1]
17-
prep_version = "6"
17+
prep_version = "7"
1818
resources = module + "_resources"
1919

2020

0 commit comments

Comments
 (0)