Checklist
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
APPDATA entry in HKCU\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
Output 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
Checklist
What You Are Seeing?
Running
refreshenvoverwrites volatile environment variables likeAPPDATA, LOCALAPPDATA, USERPROFILE, HOMEDRIVE, and HOMEPATHif 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\Environmentcontained an incorrectAPPDATAentry(C:\Users\Username\AppDatainstead ofC:\Users\Username\AppData\Roaming). After runningrefreshenv, the session'sAPPDATAwas corrupted, causing VS Code to create its data directory in the wrong location (AppData\Code instead of AppData\Roaming\Code).What is Expected?
refreshenvshould preserve volatile environment variables that Windows generates at login. The fix in #3681 preservesUSERNAME, PROCESSOR_ARCHITECTURE, TEMP, and TMPbut does not protect other volatile variables.Namely:
How Did You Get This To Happen?
APPDATAentry inHKCU\Environment(can happen via misbehaving installer or manual error)refreshenv$env:APPDATA- it now has the wrong value from the registrySystem Details
Installed Packages
Output 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