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

Support PowerShell as the default shell on Unix-like platforms #60971

Open
mklement0 opened this issue Oct 15, 2018 · 2 comments
Open

Support PowerShell as the default shell on Unix-like platforms #60971

mklement0 opened this issue Oct 15, 2018 · 2 comments
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Milestone

Comments

@mklement0
Copy link
Contributor

mklement0 commented Oct 15, 2018

Migrated and generalized from dotnet/vscode-csharp#2605

It would be great if Visual Studio Code also supported a Unix configuration where PowerShell (Core) is configured as the user's default shell.

Below is an example of where that currently fails: when using an external terminal (as controlled by setting console": "externalTerminal) for debugging, the debugger-invocation command line assumes a POSIX-like shell on Unix, and submits a command using the latter's syntax, which breaks in PowerShell.

There may be other, related cases.

In the debugger-invocation case, only a trivial tweak is required to support PowerShell too (see below).

Steps to reproduce

  • On a Unix-like platform with PowerShell Core installed, make the latter your default shell as follows: chsh -s /usr/local/bin/pwsh (macOS) or chsh -s /usr/bin/pwsh (Linux).

  • On Linux, reboot to make the new default shell take effect (not necessary on macOS).

  • Open any C# project in VS Code and debug with a ".NET Core Launch (console)" configuration with setting "console": "externalTerminal"

Desired behavior

Debugger invocation should succeed.

Current behavior

Debugger invocation fails, because the command line sent to the terminal assumes POSIX-like-shell syntax (e.g., bash), which PowerShell doesn't support.

Sample symptom:

PS /Users/jdoe> cd '/Users/jdoe/.vscode/extensions/ms-vscode.csharp-1.16.2/.debugger/';  '/Users/jdoe/.vscode/extensions/ms-vscode.csharp-1.16.2/.debugger/vsdbg' '--interpreter=vscode' '--connection=/var/folders/19/0lxcl7hd63d6fqd813glqppc0000gn/T/CoreFxPipe_vsdbg-ui-9bb838baf07245f591dda2adcfd2536f'
At line:1 char:155
+ ... -vscode.csharp-1.16.2/.debugger/vsdbg' '--interpreter=vscode' '--conn ...
+                                            ~~~~~~~~~~~~~~~~~~~~~~
Unexpected token ''--interpreter=vscode'' in expression or statement.
At line:1 char:178
+ ... ter=vscode' '--connection=/var/folders/19/0lxcl7hd63d6fqd813glqppc000 ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token ''--connection=/var/folders/19/0lxcl7hd63d6fqd813glqppc0000gn/T/CoreFxPipe_vsdbg-ui-9bb838baf07245f591dda2adcfd2536f'' in expression or statement.
+ CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken

With a quoted path to vsdbg, the call would have to be prefixed with to make PowerShell happy.

A pragmatic workaround would be not to quote the vsdbg path, which would make the call succeed in PowerShell too, without special-casing.

This should be safe as long as the user's $HOME path has no embedded spaces - something I've never seen in the Unix world.

@isidorn isidorn assigned weinand and unassigned isidorn Oct 15, 2018
@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality labels Oct 15, 2018
@weinand
Copy link
Contributor

weinand commented Nov 7, 2018

Clarification:
PowerShell on Unix-like platforms is already supported for VS Code's integrated terminal:

2018-11-07_10-15-01

I'm using these settings to configure the integrated terminal to use PowerShell:

    "terminal.integrated.shell.osx": "/usr/local/bin/powershell",
    "terminal.integrated.shellArgs.osx": []

Without this setting VS Code doesn't know how to preprocess command line arguments correctly.

What you are asking for is to support the same for the "external terminal", e.g. the launch config setting "console": "externalTerminal".

@mklement0
Copy link
Contributor Author

mklement0 commented Nov 7, 2018

Yes, this issue is about the external terminal (as noted in the "Steps to reproduce" section, but I've updated the description at the top to make that clearer).

It's more helpful to debug PowerShell itself in an external terminal, and using an external terminal is the default debug configuration in the PowerShell Core source-code repo.

Two asides:

@weinand weinand added this to the Backlog milestone Oct 18, 2021
@weinand weinand added the help wanted Issues identified as good community contribution opportunities label Oct 18, 2021
@weinand weinand removed their assignment Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

3 participants