Issue Description
If I enable profile loading and in a profile put the line
$Env:PSModulePath = $Env:PSModulePath + ';<CUSTOM_PATH>' and launch VS Code, after the integrated terminal loads, the new path does not exist and C:\Users\<User>\.vscode\extensions\ms-vscode.powershell-1.5.1\modules is missing. Note that other environment variables I set still exist.
Environment Information
Visual Studio Code
| Name |
Version |
| Operating System |
Windows_NT x64 10.0.15063 |
| VSCode |
1.18.1 |
| PowerShell Extension Version |
1.5.1 |
PowerShell Information
| Name |
Value |
| PSVersion |
6.0.0-rc |
| PSEdition |
Core |
| GitCommitId |
v6.0.0-rc |
| OS |
Microsoft Windows 10.0.15063 |
| Platform |
Win32NT |
| PSCompatibleVersions |
1.0 2.0 3.0 4.0 5.0 5.1.10032.0 6.0.0-rc |
| PSRemotingProtocolVersion |
2.3 |
| SerializationVersion |
1.1.0.1 |
| WSManStackVersion |
3.0 |
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
| Extension |
Author |
Version |
| code-spell-checker |
streetsidesoftware |
1.5.1 |
| markdown-all-in-one |
yzhang |
0.11.2 |
| mssql |
ms-mssql |
1.2.1 |
| PowerShell |
ms-vscode |
1.5.1 |
| vscode-eslint |
dbaeumer |
1.4.3 |
| xml |
DotJoshJohnson |
1.9.2 |
OK this might be caused by PS Core:
You don’t normally see this problem in PS Core but with the VSCode extension, PS Core is started, a script is run to import and start PSES. At this point the env var is correct. However,once PSES starts executing it has to set up its PSHost UI and I “think” in the process of doing that, the above code is executed which resets the PSModulePath. I haven’t had a chance to verify this yet in the debugger. It’s a theory at this point. If this is the case, perhaps we can stash and restore the PSModulePath in PSES.
Is that directory a junction/mount point or anything else weird like that? The other thing that would be good to know is if this happens in pure PowerShell Core - no VSCode.
Are you sure you modifying the profile in
Documents\PowerShellinstead of the one inDocuments\WindowsPowerShell? I can’t repro this with PS Core 6.0.0-rc.BTW, init script has been discussed here #190 and #880.