Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug PowerShell 5.1 Untitled Files Not Working #3391

Closed
SoulSeekkor opened this issue Jun 2, 2021 · 8 comments
Closed

Debug PowerShell 5.1 Untitled Files Not Working #3391

SoulSeekkor opened this issue Jun 2, 2021 · 8 comments
Labels
Area-Debugging Bug: PowerShell 5.1 Bugs when using PowerShell 5.1. Resolution-Answered Will close automatically.

Comments

@SoulSeekkor
Copy link

Issue Description

Porting an issue from here that was determined to be an extension issue specifically. Had previously created this issue but it was closed prematurely.

Unless my memory is incorrect, one of the biggest advantages to VS Code over ISE was that we used to be able to set breakpoints and debug Powershell files that were untitled and not saved yet.

With this version I've noticed that no longer works, I can set a breakpoint on an untitled tab and it does not stop, it simply runs the entire script without stopping.

image

Attached Logs

Follow the instructions in the README about
capturing and sending logs.

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.19042
VSCode 1.56.0
PowerShell Extension Version 2021.2.2

PowerShell Information

Name Value
PSVersion 5.1.19041.906
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.19041.906
BuildVersion 10.0.19041.906
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
material-icon-theme PKief 4.6.0
powershell ms-vscode 2021.2.2
vscode-inline-values-powershell TylerLeonhardt 0.0.5
@ghost ghost added the Needs: Triage Maintainer attention needed! label Jun 2, 2021
@andyleejordan
Copy link
Member

Hi, please try the latest release (from yesterday) v2021.5.1. I see your comment here #3343 (comment). I cannot repro this on my Mac with PowerShell 7 and 2021.5.1.

@andyleejordan andyleejordan added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Jun 2, 2021
@SoulSeekkor
Copy link
Author

Unfortunately I have and it still does not stop on the breakpoint. This is with VS Code version 1.56.2 now.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jun 2, 2021
@andyleejordan
Copy link
Member

Can you try PowerShell 7? Just trying to narrow down the cause.

@SoulSeekkor
Copy link
Author

I can't install it to try it right now, and we don't use anything past 5.1 since there's no good way to reliably make sure all client machines have it. Assuming my personal machine has the same issue I can try it later today and update this issue with my findings.

@andyleejordan
Copy link
Member

As far as I know, debugging untitled files in PowerShell 5.1 is unsupported (at least, it's not working now, and hasn't worked since I started maintaining the extension based on bug reports). I would suggest using the new (currently only in Insiders) configuration setting to always prompt to save files when debugging if you're still using PowerShell 5.1:

"[powershell]": {
    "debug.saveBeforeStart": "allEditorsInActiveGroup"
}

As per #3357 we no longer prompt to save untitled files.

@andyleejordan andyleejordan changed the title Debug Powershell Untitled Files Not Working Debug PowerShell 5.1 Untitled Files Not Working Jun 2, 2021
@SoulSeekkor
Copy link
Author

Okay, I could have sworn it had always worked in the past and was one of the nicer improvements over using ISE in that you could debug a quick test without having to leave junk files everywhere. If that is no longer the case and won't be continued then you may close this out,.

The prompting to save files which changed (broke imo, it never used to have that behavior) where they included that particular setting to allow for it to be changed to 'nonUntitledEditorsInActiveGroup' so that it behaved like it has for years before that maybe changed how the debugger interacts with these files, some sort of conflict perhaps? The Powershell extension expects it to be saved now but it isn't since VS Code (with that setting) doesn't prompt to do so, and simply runs it instead. That setting is in production now as well, but we can't really move off of Powershell 5.1 since it is what comes with Windows. Unfortunately there is no reliable way to ensure that thousands of endpoints all have Powershell 7 when we run scripts against them, more so without adversely affecting certain environments.

@andyleejordan
Copy link
Member

The prompting to save files which changed (broke imo, it never used to have that behavior)

I think what happened was that upstream VS Code added behavior to prompt to save files, or in some way changed it such that it started happening. Later they added the configurable option nonUntitledEditorsInActiveGroup and it was recommended we enable it by default to avoid the prompting, since most users (using the extension and PowerShell 7) don't need to save the untitled files, only the subset still on PowerShell 5.1. But it is certainly a user configurable option.

we can't really move off of Powershell 5.1 since it is what comes with Windows. Unfortunately there is no reliable way to ensure that thousands of endpoints all have Powershell 7 when we run scripts against them, more so without adversely affecting certain environments.

This is certainly a pain point I think the whole team would like to see addressed, as 5.1 is in development freeze (hence the existence of 6 and now 7), but we need a version of .NET Core that has a support lifecycle as long as the Windows support lifecycle in order to include PowerShell 7 on Windows by default. That's my understanding of the situation anyway.

@andyleejordan andyleejordan added the Bug: PowerShell 5.1 Bugs when using PowerShell 5.1. label Jun 14, 2021
@rjmholt
Copy link
Contributor

rjmholt commented Jun 14, 2021

I could have sworn it had always worked in the past and was one of the nicer improvements over using ISE in that you could debug a quick test without having to leave junk files everywhere

Windows PowerShell doesn't have the breakpoint APIs required to debug a file in memory like that. Those APIs were added in PS 7 and we added support for them in PowerShell/PowerShellEditorServices#1119. AFAIK, prior to that we never supported untitled file debugging.

@rjmholt rjmholt removed the Needs: Maintainer Attention Maintainer attention needed! label Jun 14, 2021
@ghost ghost closed this as completed Jun 15, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debugging Bug: PowerShell 5.1 Bugs when using PowerShell 5.1. Resolution-Answered Will close automatically.
Projects
None yet
Development

No branches or pull requests

3 participants