Skip to content

The agent that grows with you

fix(desktop): Windows marker probe and spawn scripts no longer assign the read-only $HOME

teknium1b4709b8508fe
diff --git a/apps/desktop/electron/windows-remote-lifecycle.test.ts b/apps/desktop/electron/windows-remote-lifecycle.test.ts
index 9f4c8c64ea2..eb2f686181c 100644
--- a/apps/desktop/electron/windows-remote-lifecycle.test.ts
+++ b/apps/desktop/electron/windows-remote-lifecycle.test.ts
@@ -104,6 +104,10 @@ test('every emitted PowerShell script keeps try blocks attached to their catch/f
assert.equal(scripts.length, 4)
for (const script of scripts) {
assert.doesNotMatch(script, /}\s*;\s*(?:catch|finally)\b/)
+ // `$HOME`, `$HOST`, `$PID`, ... are read-only automatic variables: assigning
+ // one throws "Cannot overwrite variable" at run time, so the probe exits 1
+ // and the marker gate never observes CLEAR.
+ assert.doesNotMatch(script, /\$(?:home|host|pid|profile|pwd|input|args|error)\s*=/i)
}
assert.ok(scripts.slice(0, 2).every(script => /}catch \[Management\.Automation\.ItemNotFoundException\]/.test(script)))
})
diff --git a/apps/desktop/electron/windows-remote-lifecycle.ts b/apps/desktop/electron/windows-remote-lifecycle.ts
index 6d74b082382..d042a51bcd2 100644
--- a/apps/desktop/electron/windows-remote-lifecycle.ts
+++ b/apps/desktop/electron/windows-remote-lifecycle.ts
@@ -95,9 +95,9 @@ public static class HermesMarkerNoFollow {
'$parent=$item.Parent.FullName;if(-not $parent -or $parent -eq $current){break};$current=$parent;$first=$false',
'}',
'}',
- `$home=${psLiteral(hermesHome)}`,
- '$installRoot=$home',
- '$parent=Split-Path -Parent $home',
+ `$hermesHome=${psLiteral(hermesHome)}`,
+ '$installRoot=$hermesHome',
+ '$parent=Split-Path -Parent $hermesHome',
'if((Split-Path -Leaf $parent) -ieq "profiles"){$installRoot=Split-Path -Parent $parent}',
'$marker=Join-Path $installRoot ".hermes-update-in-progress"',
'$result="UNCERTAIN"',
@@ -250,9 +250,9 @@ function atomicWindowsSpawnCommand(runtime, reservation: any = {}) {
const script = [
'$ErrorActionPreference="Stop"',
- `$home=${psLiteral(runtime.hermesHome)}`,
- '$installRoot=$home',
- '$parent=Split-Path -Parent $home',
+ `$hermesHome=${psLiteral(runtime.hermesHome)}`,
+ '$installRoot=$hermesHome',
+ '$parent=Split-Path -Parent $hermesHome',
'if((Split-Path -Leaf $parent) -ieq "profiles"){$installRoot=Split-Path -Parent $parent}',
'$marker=Join-Path $installRoot ".hermes-update-in-progress"',
'$mutexPath=$marker+".mutex"',