vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

PowerShell profile not loaded in temporary PowerShell Integrated Console when `powershell.debugging.createTemporaryIntegratedConsole` is set to true

Open ohadschn opened this issue 7 years ago • 5 comments

System Details

  • Operating system name and version: Windows 10 (1803)
PS C:\Users\ohads\Documents\PowerShell> code -v
1.25.1
1dfc5e557209371715f655691b1235b6b26a06be
x64
PS C:\Users\ohads\Documents\PowerShell> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      8      2      0


PS C:\Users\ohads\Documents\PowerShell> code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
PS C:\Users\ohads\Documents\PowerShell> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.165
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.165
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

The PowerShell terminal and the PowerShell Integrated Console both load PowerShell profiles. However, when setting powershell.debugging.createTemporaryIntegratedConsole to true, profiles are not loaded. Looking at process explorer, I believe powershell.exe is being executed with -NoProfile. This is undocumented, inconsistent, and IMO undesired.

ohadschn avatar Aug 06 '18 17:08 ohadschn

The integrated console is always started with -NoProfile because our custom host does the profile processing.

That profile processing step is probably skipped for temporary consoles though. Not sure if that was a design decision or something that fell threw the cracks. Either way, profile loading for temporary consoles should definitely be an option (and probably on by default)

SeeminglyScience avatar Aug 07 '18 14:08 SeeminglyScience

Early on the extension didn't have a custom host and debug input/output happened via the Debug Console. I think we suppressed profiles back then. The addition of the "temporary console" was to attempt to bring back something like that debug experience where you started with a fresh & clean session every time. Debugging with persistent state can be very handy but also somewhat dangerous. You can fool yourself into thinking your script works when in fact, in a clean session it won't work.

While I can see having a setting to enable profile processing in the temp console, I personally don't think it should be the default. Relying (intentionally or unintentionally) on local state created by your profile, is not a recipe for success when that script is moved to another machine with a different profile configuration.

rkeithhill avatar Aug 07 '18 16:08 rkeithhill

Hi,

I use temporary session because I write powershell Classes. But my prompt is often too long and I'd like to set it in the profile.

I sadly don't have code to contribute. Maybe if I could pass the prompt somehow in the vscode launch.json that would be great.

Thanks a lot!

webtroter avatar Aug 04 '21 00:08 webtroter