Skip to content

fix(system): Update TargetEnvVar instead of PATH - #6580

Open
xworld21 wants to merge 1 commit into
ScoopInstaller:developfrom
xworld21:add-path-targetenvvar
Open

fix(system): Update TargetEnvVar instead of PATH#6580
xworld21 wants to merge 1 commit into
ScoopInstaller:developfrom
xworld21:add-path-targetenvvar

Conversation

@xworld21

Copy link
Copy Markdown

Description

The functions Add-Path, Remove-Path admit an argument -TargetEnvVar which would update the correct profile or system environment variable, but would always act on PATH in the current session.

I simply replaced $env:PATH with Get/Set-Content "env:$TargetEnvVar" to fix this. I have also updated the message 'Adding (...) to your path', so there will be a visible change to 'Adding (...) to your PATH'.

(I suppose this doesn't merit an entry in the CHANGELOG... does it?)

Motivation and Context

Closes #6579.

How Has This Been Tested?

I have checked the functions manually in the terminal, including with non-existing variables (hence the -ErrorAction Ignore).

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f08bebe-4d04-42e7-b698-00647e6a9028

📥 Commits

Reviewing files that changed from the base of the PR and between 6110af0 and 73be289.

📒 Files selected for processing (1)
  • lib/system.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/system.ps1

Summary by CodeRabbit

  • Bug Fixes
    • Corrected current-session environment variable updates to target the selected variable.
    • Improved status messages to accurately identify the environment variable being modified.

Walkthrough

Add-Path and Remove-Path now use $TargetEnvVar for current-session reads and writes. Their status messages identify the selected environment variable.

Changes

Target environment variable handling

Layer / File(s) Summary
Current-session target updates
lib/system.ps1
Add-Path and Remove-Path now read and write env:$TargetEnvVar. Status messages identify $TargetEnvVar instead of hardcoding “path.”
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix: updating TargetEnvVar instead of the hardcoded PATH variable.
Description check ✅ Passed The description explains the TargetEnvVar bug, the implementation change, testing, and issue reference.
Linked Issues check ✅ Passed The changes update the current session’s specified TargetEnvVar instead of always modifying PATH, satisfying issue #6579.
Out of Scope Changes check ✅ Passed The changes are limited to the TargetEnvVar fix and related status-message updates described in issue #6579.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e1e2bf0-1c3a-48c9-8e32-812d0ce29bf0

📥 Commits

Reviewing files that changed from the base of the PR and between cbd7c64 and 6110af0.

📒 Files selected for processing (1)
  • lib/system.ps1

Comment thread lib/system.ps1
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.

1 participant