Skip to content

fix: PowerShell Add-ToUserPath corrupts PATH when single entry exists#1000

Merged
Wirasm merged 1 commit intocoleam00:devfrom
RivoLink:fix/powershell-add-to-user-path-single-entry
Apr 9, 2026
Merged

fix: PowerShell Add-ToUserPath corrupts PATH when single entry exists#1000
Wirasm merged 1 commit intocoleam00:devfrom
RivoLink:fix/powershell-add-to-user-path-single-entry

Conversation

@RivoLink
Copy link
Copy Markdown
Contributor

@RivoLink RivoLink commented Apr 9, 2026

Bug: PowerShell Add-ToUserPath corrupts PATH when only one entry exists


Problem

When the user PATH contains exactly one entry, the following line returns a plain string instead of an array:

$pathParts = $currentPath -split ';' | Where-Object { $_ -ne '' }

PowerShell only returns an array from a pipeline when there are 2 or more elements. With a single element, $pathParts is typed as a [string].

This causes the next line to behave as string concatenation instead of array append:

$pathParts += $Dir
# "C:\existing" += "C:\new"
# → "C:\existingC:\new"  ❌  instead of  @("C:\existing", "C:\new")

The resulting PATH becomes corrupted:

C:\existingC:\new   ← missing semicolon separator

Affected scenario

This bug only triggers when the Windows user PATH contains exactly one entry — which is common on freshly configured machines or minimal environments.


Fix

Wrap the pipeline in @() to force an array regardless of the number of elements:

# Before
$pathParts = $currentPath -split ';' | Where-Object { $_ -ne '' }

# After
$pathParts = @($currentPath -split ';' | Where-Object { $_ -ne '' })

Testing

To reproduce and verify the fix:

# Simulate a single-entry user PATH
[Environment]::SetEnvironmentVariable('Path', 'C:\TestOnly', 'User')

# Call the function
Add-ToUserPath 'C:\NewTool'

# Expected
[Environment]::GetEnvironmentVariable('Path', 'User')
# → "C:\TestOnly;C:\NewTool"  ✅

# Actual (before fix)
# → "C:\TestOnlyC:\NewTool"   ❌

Summary by CodeRabbit

  • Bug Fixes
    • Fixed PATH environment variable parsing in the installation process to ensure the application is properly registered and accessible on all systems. This resolves potential issues where the application might not be correctly added to the system PATH under certain conditions, particularly on systems with non-standard configurations or existing PATH entries.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 518cc68b-058d-4ad2-a035-19a5ad0cdff2

📥 Commits

Reviewing files that changed from the base of the PR and between 50f96f8 and 638362d.

📒 Files selected for processing (1)
  • scripts/install.ps1

📝 Walkthrough

Walkthrough

Updated PATH parsing in a PowerShell installation script to explicitly wrap the split-and-filter operation result in an array constructor, ensuring the $pathParts variable reliably maintains array type for subsequent membership checks.

Changes

Cohort / File(s) Summary
PowerShell PATH Handling Fix
scripts/install.ps1
Modified Add-ToUserPath function to wrap split-and-filter result with @(...) array constructor, ensuring consistent array type behavior for -notin membership check when validating $Dir.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 An array that danced in PowerShell's light,
Now wrapped in @(...) — oh what a sight!
The PATH installation script's fix is quite neat,
Type-coercion troubles now face defeat!
Hop along smoothly, one line at a time. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides detailed problem explanation, root cause, fix details, and reproduction steps, but does not follow the required template structure with sections like Summary, UX Journey, Architecture Diagram, Validation Evidence, Security Impact, Compatibility, Human Verification, Side Effects, Rollback Plan, and Risks. Reformat the description to follow the repository's required template structure, including all required sections such as Summary, Change Metadata, Validation Evidence, Security Impact, Compatibility, Human Verification, Side Effects, and Rollback Plan.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main bug being fixed: PowerShell Add-ToUserPath corrupts PATH when a single entry exists.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

GQAdonis pushed a commit to GQAdonis/Archon that referenced this pull request Apr 9, 2026
…idation (coleam00#1000)

The generate-yaml node prompt contained $nodeId.output and $other-node.output
as documentation examples. The DAG validator's regex matched these as real node
references and rejected the workflow. Wrap placeholders in angle brackets
($<nodeId>.output) so the regex no longer matches them.

Fixes coleam00#1000
@Wirasm Wirasm merged commit 53cabd4 into coleam00:dev Apr 9, 2026
3 of 4 checks passed
@Wirasm Wirasm mentioned this pull request Apr 10, 2026
Tyone88 pushed a commit to Tyone88/Archon that referenced this pull request Apr 16, 2026
…idation (coleam00#1000)

The generate-yaml node prompt contained $nodeId.output and $other-node.output
as documentation examples. The DAG validator's regex matched these as real node
references and rejected the workflow. Wrap placeholders in angle brackets
($<nodeId>.output) so the regex no longer matches them.

Fixes coleam00#1000
@RivoLink RivoLink deleted the fix/powershell-add-to-user-path-single-entry branch April 21, 2026 16:17
@RivoLink RivoLink restored the fix/powershell-add-to-user-path-single-entry branch April 21, 2026 16:18
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
…idation (coleam00#1000)

The generate-yaml node prompt contained $nodeId.output and $other-node.output
as documentation examples. The DAG validator's regex matched these as real node
references and rejected the workflow. Wrap placeholders in angle brackets
($<nodeId>.output) so the regex no longer matches them.

Fixes coleam00#1000
Sign up for free to 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.

2 participants