-
Notifications
You must be signed in to change notification settings - Fork 930
Description
Checklist
- I confirm there are no unresolved issues reported on the Chocolatey Status page.
- I have verified this is the correct repository for opening this issue.
- I have verified no other issues exist related to my problem.
- I have verified this is not an issue for a specific package.
- I have verified this issue is not security related.
- I confirm I am using official, and not unofficial, or modified, Chocolatey products.
What You Are Seeing?
Running refreshenv overwrites volatile environment variables like APPDATA, LOCALAPPDATA, USERPROFILE, HOMEDRIVE, and HOMEPATH if they exist in the registry. This is the same class of bug as #3681 (fixed for TEMP/TMP in v2.6.0) and related to #3021 (PATH entries being overwritten).
In my case, HKCU\Environment contained an incorrect APPDATA entry (C:\Users\Username\AppData instead of C:\Users\Username\AppData\Roaming). After running refreshenv, the session's APPDATA was corrupted, causing VS Code to create its data directory in the wrong location (AppData\Code instead of AppData\Roaming\Code).
What is Expected?
refreshenv should preserve volatile environment variables that Windows generates at login. The fix in #3681 preserves USERNAME, PROCESSOR_ARCHITECTURE, TEMP, and TMP but does not protect other volatile variables.
Namely:
- APPDATA
- LOCALAPPDATA
- USERPROFILE
- HOMEDRIVE
- HOMEPATH
How Did You Get This To Happen?
- Have an incorrect
APPDATAentry inHKCU\Environment(can happen via misbehaving installer or manual error) - Run
refreshenv - Check
$env:APPDATA- it now has the wrong value from the registry
System Details
- Operating System: Windows 11 24H2 LTSC Version 10.0.26100.6899]
- Windows PowerShell version: 7.5.4
- Chocolatey CLI Version: 2.6.0
- Chocolatey Licensed Extension version: N/A
- Chocolatey License type: Open Source
- Terminal/Emulator: Windows Terminal (pwsh)
Installed Packages
N/AOutput Log
Unable to provide output log as the issue has been fixed at my end (removed the bad actor in environment)Additional Context
No response