Skip to content

fix(installer): pin background jobs to a local cwd — no UNC noise on roaming-profile machines - #437

Merged
shujaatTracebloc merged 1 commit into
developfrom
fix/409-unc-job-cwd
Jul 27, 2026
Merged

fix(installer): pin background jobs to a local cwd — no UNC noise on roaming-profile machines#437
shujaatTracebloc merged 1 commit into
developfrom
fix/409-unc-job-cwd

Conversation

@LukasWodka

@LukasWodkaLukasWodka commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the red RemoteException / CMD.EXE ... UNC paths are not supported blocks that appear 2–6 times per install on machines whose home directory is a UNC share (roaming profiles — the hospital/enterprise norm). Root cause: PowerShell background jobs start their runspace in $HOME, so every cmd /c inside a job inherits a UNC cwd. Observed live on a customer install (2026-07-27).

Change

  • New shared $script:JobInit scriptblock — if ($env:SystemRoot) { Set-Location $env:SystemRoot } — passed as -InitializationScript at all five Start-Job sites (wsl --update, wsl --set-default-version 2, wsl --list, NVIDIA toolkit install + verify).
  • Pester: AST gate asserting everyStart-Job in the script carries -InitializationScript (so new jobs can't regress), plus a behavioral test that the init block moves the job cwd and is a no-op when SystemRoot is unset (Linux CI).
  • manifest.sha256 regenerated.

Type

Bug fix

Test plan

  • Full Pester suite locally on pwsh 7.5 (mirrors CI invocation): 155 passed, 0 failed, 8 skipped (3 new).
  • scripts/gen-manifest.sh run; --check clean.
  • On a Windows box with a UNC home, wsl --update/toolkit steps no longer emit CMD.EXE UNC warnings (jobs run from C:\Windows).

🤖 Generated with Claude Code


Note

Low Risk
Installer-only UX fix for job initialization; no auth, cluster, or credential logic changes.

Overview
Fixes misleading red RemoteException noise during Windows installs when the user profile home is a UNC path (common with roaming profiles). PowerShell Start-Job runspaces inherit that cwd, so nested cmd /c calls emit CMD’s “UNC paths are not supported” message even when WSL steps succeed.

Introduces $script:JobInit (Set-Location $env:SystemRoot when set) and passes it as -InitializationScript on all five Start-Job sites (WSL update/default version, WSL list, NVIDIA toolkit install/verify).

Pester adds an AST gate so every Start-Job in install-k8s.ps1 must include -InitializationScript, plus a behavioral test for the init block. manifest.sha256 is updated for the installer script.

Reviewed by Cursor Bugbot for commit 6132abf. Bugbot is set up for automated code reviews on this repo. Configure here.

…roaming-profile machines (#409)
PowerShell background jobs spawn their runspace in $HOME; on managed
machines with roaming profiles that is a UNC share, and every cmd.exe a
job starts there prints 'CMD.EXE was started with the above path as the
current directory. UNC paths are not supported.' plus a RemoteException
error record — 2-6 alarming red blocks on an otherwise healthy install.
All five Start-Job sites (wsl --update, wsl --set-default-version,
wsl --list, NCT install, NCT verify) now pass a shared
-InitializationScript that pins the job to $env:SystemRoot (always
local; no-op off-Windows). An AST-based Pester gate fails any future
Start-Job that forgets it.
Closes#409
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LukasWodkaLukasWodka self-assigned this Jul 27, 2026
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

bugbot run

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6132abf. Configure here.

@shujaatTraceblocshujaatTracebloc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the code, not just the CI state.

Completeness: exactly 5 Start-Job sites in install-k8s.ps1, all 5 now pass -InitializationScript $JobInit. No other job primitive (Start-ThreadJob/-AsJob/Invoke-Command) exists, so nothing was missed — and the AST-gate test makes that guarantee permanent.

Correctness:-InitializationScript runs in the job runspace before the main block, so Set-Location $env:SystemRoot moves cwd off the UNC share before any cmd /c inherits it. SystemRoot is always local on Windows; the guard makes it a no-op off-Windows. $script:JobInit is correctly script-scoped so the unqualified $JobInit inside the functions resolves.

No output pollution (the real risk): Set-Location without -PassThru emits nothing, so the parsed sites stay clean — $distroRaw (wsl --list) receives only $raw, and the update path keys off job State, not output. The behavioral test's Receive-Job … | Should -Be "ran" proves the init block contributes no output.

Manifest regenerated; drift check green. All CI green (Pester on windows + ubuntu); Bugbot clean on 6132abf.

LGTM 🚀

@shujaatTracebloc

Copy link
Copy Markdown
Contributor

Backing-ref link: this PR landed the fix for #409 (background jobs pinned to a local cwd — no UNC noise). Merged to develop as ab940e5; the issue was closed manually since auto-close only fires on the default branch.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@LukasWodka@shujaatTracebloc@divyasinghds