Skip to content

fix(shared): repair stale Windows PATH capture - #7411

Closed
mrmg wants to merge 1 commit into
pingdotgg:mainfrom
mrmg:agent/fix-windows-path-repair
Closed

fix(shared): repair stale Windows PATH capture#7411
mrmg wants to merge 1 commit into
pingdotgg:mainfrom
mrmg:agent/fix-windows-path-repair

Conversation

@mrmg

@mrmg mrmg commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #7406

Problem

On Windows, the desktop app can inherit a stale process PATH after a Node upgrade. The one-click provider update then cannot find Node even though it is installed.

Fix

Capture PATH from the process, machine, and user scopes in precedence order, while preserving the existing process-only handling for the other captured variables.

Verification

  • vp test run packages/shared/src/shell.test.ts
  • vp run --filter @t3tools/shared typecheck
  • vp fmt --check packages/shared/src/shell.ts packages/shared/src/shell.test.ts

Created with GPT-5.6-terra in T3 Code.

Note

Fix stale Windows PATH capture by reading Process, Machine, and User scopes

The buildWindowsEnvironmentCaptureCommand function in shell.ts previously read PATH from a single environment scope, which could miss persisted Machine or User PATH entries. It now collects PATH from all three Windows scopes (Process, Machine, User), filters out null/empty values, and joins them with ;. Other environment variables retain the original single-value behavior.

Macroscope summarized 9b6490c.


Note

Medium Risk
Changes how Windows PATH is built for spawn and command resolution; impact is limited to shared shell env logic and is covered by new tests.

Overview
Fixes Windows desktop PATH hydration when the app process still has an outdated PATH after a Node install or upgrade.

PATH capture in buildWindowsEnvironmentCaptureCommand no longer relies on a single GetEnvironmentVariable call. It now reads Process, Machine, and User scopes in that order, drops empty values, and joins them with ;. Other captured variables keep the previous single-value behavior.

A unit test asserts the generated PowerShell command queries all three scopes and that the merged PATH is returned.

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

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2aa79076-cf74-4879-a5ce-b6bc25252a18

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Aug 18, 2026
@mrmg
mrmg marked this pull request as ready for review August 18, 2026 15:30

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9b6490c. Configure here.

name === "PATH"
? [
`$value = @([Environment]::GetEnvironmentVariable('${name}', 'Process'), [Environment]::GetEnvironmentVariable('${name}', 'Machine'), [Environment]::GetEnvironmentVariable('${name}', 'User')) | Where-Object { $null -ne $_ -and $_.Length -gt 0 }`,
"if (@($value).Count -gt 0) { Write-Output ($value -join ';') }",

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.

PATH join corrupts single scope

Medium Severity

When only one of Process, Machine, or User PATH is non-empty, PowerShell unwraps the filtered result to a scalar string. $value -join ';' then joins individual characters, so the captured PATH becomes corrupted and Windows command resolution breaks.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9b6490c. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verified this against PowerShell join semantics: binary -join treats a scalar as one item, so a single non-empty PATH scope remains unchanged rather than being split into characters. Microsoft documents that -join handles single items (for example, 1 -join "-" returns 1). The filtered value is therefore safe without an additional array wrapper.

@macroscopeapp

macroscopeapp Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR has an unresolved review comment identifying a potential bug where the PATH could be corrupted when only one environment scope is non-empty. The PowerShell join behavior on scalar strings needs verification before merging.

You can add or adjust custom eligibility rules. Learn more.

@mrmg

mrmg commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Babysitting note: the only failing status is Vercel’s marketing deployment authorization (vercel.com/git/authorize). It is external to this change; CI Check, Test, Release Smoke, and automated correctness checks passed on 9b6490c. No source change is appropriate for that status.

@t3dotgg

t3dotgg commented Aug 28, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-5.6 Sol responding on behalf of Theo

We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together.

We are keeping OPEN #8465 as the review path for refreshing the Windows PATH before provider checks. The stale-capture tests here remain useful reference.

If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed.

@t3dotgg t3dotgg closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: One-click provider update fails with spawn NotFound when the app inherits a stale Windows PATH

2 participants