vscode-powershell: VSCode Extension v2022.8.5 initializes wrong user profile path
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
On a system with folder redirection for $env:AppData Folder to a UNC Path, the PowerShell extension does not resolve that path correctly on startup.
PowerShell Version
$PSVersionTable
Name Value
---- -----
PSVersion 7.2.6
PSEdition Core
GitCommitId 7.2.6
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visual Studio Code Version
code --version
1.72.0
64bbfbf67ada9953918d72e1df2f4d8e537d340e
x64
Extension Version
code --list-extensions --show-versions | select-string powershell
ms-vscode.powershell@2022.8.5
Steps to Reproduce
The Extension creates the initial session files in C:\<shareName>\<UserName>\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-<ID>.json and the intial log Folders in C:\<shareName>\<UserName>\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\<RandomID> on the local harddrive.
After creating these files however, the extension tries to use at least the log files from the UNC share (which aren’t present there) and creates a partial log for the respective session in \\<ServerName>\<ShareName>\<UserName>\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\<RandomID>.
The initial call from the VS Code Terminal Console invokes a scriptblock like this : Import-Module 'c:\Users\<UserName>\.vscode\extensions\ms-vscode.powershell-2022.8.5\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2022.8.5' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\<UserName>\.vscode\extensions\ms-vscode.powershell-2022.8.5\modules' -EnableConsoleRepl -StartupBanner "<BannerText>" -LogLevel 'Normal' -LogPath '\<ShareName>\<UserName>\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\<RandomID>\EditorServices.log' -SessionDetailsPath '\<ShareName>\<UserName>\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-<ID>.json' -FeatureFlags @()
Instead of what I believe would be correct:
Import-Module 'c:\Users\<UserName>\.vscode\extensions\ms-vscode.powershell-2022.8.5\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2022.8.5' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\<UserName>\.vscode\extensions\ms-vscode.powershell-2022.8.5\modules' -EnableConsoleRepl -StartupBanner "<BannerText>" -LogLevel 'Normal' -LogPath '\\<ServerName>\<ShareName>\<UserName>\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\<RandomID>\EditorServices.log' -SessionDetailsPath '\\<ServerName>\<ShareName>\<UserName>\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-<ID>.json' -FeatureFlags @()
Visuals
No response
Logs
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 27 (15 by maintainers)
@andschwa i think the issue here is that
vscode-userdatais used for UNC file paths when it probably shouldn’t (since UNC paths are just normalfile:paths).I’ve heard that @sandy081 @bpasero are likely the ones to talk to.
tl;dr: the
vscode-userdatascheme is being used for the global storage URI when that uses a UNC path.I’m working on getting these properties emitted by the logger!
@andschwa @TylerLeonhardt to continue working on my project, I had had the group policy removed that enforced folder redirection for the
%AppData%folder. With that removed, it went back to normal and the local%UserProfile%\AppData\Roamingfolder on my harddrive was again used for theglobalStorageUriwithout any issues.I don’t know when I’ll get around to set up a test machine to reproduce the issue. All I can do atm is tell you the value the RegistryKey
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Explorer\User Shell Foldershad a Value forAppDatawas set to a UNC path like\\<Server>\<ShareName>\AppData\Roaming\.It might be different, if there’s an actual drive letter mapped to that share instead of a UNC path.
To setup folder redirection and offline files for user profile folders via Group Policy this article https://learn.microsoft.com/en-us/windows-server/storage/folder-redirection/deploy-folder-redirection is maybe a hint.
PS: Since there were write actions to both the correct share name and the incorrect local hard drive folder, I’d think that in one place combining the path variable caused the issue, because I doubt that the value for
gobalStorageUrichanged during runtime. However currently I can’t give you the value that was stored in thegobalStorageUriwhen the error happened.Currently I’d suggest to avoid using folder redirection for AppData folder.