fix(install): expand 8.3 short %TEMP% so Windows Node/Electron stages don't abort

On a Windows profile whose folder name contains a space (e.g. "First Last"),
Windows can expose %TEMP%/%TMP% as an 8.3 short path
(C:\Users\FIRST~1.LAS\AppData\Local\Temp). PowerShell's FileSystem provider
mishandles the "~1.ext" component when the path reaches a provider cmdlet such
as `Tee-Object -FilePath`, throwing:

  An object at the specified path C:\Users\FIRST~1.LAS does not exist.

Every Node/Electron install+build stage streams its log to %TEMP% via
Tee-Object, so they all abort with that error (browser-tools npm, Playwright,
TUI npm, and the hard-failing desktop build), while the Python/uv stages --
which never write a side log to %TEMP% through a provider cmdlet -- succeed.

Normalize %TEMP%/%TMP% to their long form once, up front, so every downstream
cmdlet and child process sees a path the provider can resolve.

Fixes #39308
This commit is contained in:
xxxigm 2026-06-05 07:21:59 +07:00 committed by Teknium
parent e74033b39b
commit ac83365d96

View file

@ -122,6 +122,16 @@ function ConvertTo-LongPath {
return $Path
}
foreach ($tmpVar in @('TEMP', 'TMP')) {
$current = [Environment]::GetEnvironmentVariable($tmpVar)
if ($current) {
$expanded = ConvertTo-LongPath $current
if ($expanded -and $expanded -ne $current) {
Set-Item -Path "Env:$tmpVar" -Value $expanded
}
}
}
# ============================================================================
# Configuration
# ============================================================================