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

Extension not honoring terminal.integrated.automationShell #14221

Closed
mbikovitsky opened this issue Oct 2, 2020 · 6 comments
Closed

Extension not honoring terminal.integrated.automationShell #14221

mbikovitsky opened this issue Oct 2, 2020 · 6 comments
Assignees
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug

Comments

@mbikovitsky
Copy link

Environment data

  • VS Code version: 1.49.2
  • Extension version: v2020.9.112786
  • OS and version: Windows 10 Version 2004 (Build 19041.508)
  • Python version: 3.7.7
  • Type of virtual environment used: pipenv
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: N/A
  • Value of the python.languageServer setting: Pylance

Expected behaviour

When launching a debug session, the extension should issue commands suitable for the shell specified in terminal.integrated.automationShell, if this setting is defined, instead of terminal.integrated.shell.

Actual behaviour

VS Code indeed launches the shell specified in terminal.integrated.automationShell, however the extension issues commands suitable for terminal.integrated.shell.

For instance, if terminal.integrated.shell.windows points to PowerShell and terminal.integrated.automationShell.windows points to cmd.exe, the extension erroneously issues the & path/to/virtualenv/Scripts/Activate.ps1 command.

Steps to reproduce:

To reproduce on Windows:

  1. Set terminal.integrated.shell.windows to "C:\\Program Files\\PowerShell\\7\\pwsh.exe".
  2. Set terminal.integrated.automationShell.windows to "C:\\Windows\\System32\\cmd.exe".
  3. Launch a Python debugging session.
@mbikovitsky mbikovitsky added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Oct 2, 2020
@karthiknadig karthiknadig self-assigned this Oct 5, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Oct 5, 2020
@karthiknadig
Copy link
Member

@mbikovitsky Just to confirm. terminal.integrated.automationShell.windows is used by tasks, do you have any pre-launch tasks configured? If so when that task runs it will use the automationShell. The debugger itself uses the integrated terminal. Can you confirm that the problem is when we attempt to activate in the automation shell we use the same configuration as for integrated one? Or are you expecting that debugger should use the automation shell?

@mbikovitsky
Copy link
Author

I do not have any pre-launch tasks configured.

The behaviour I'm observing is that if the integrated terminal is set to PowerShell and the automation terminal is set to cmd.exe, the debugger launches in cmd.exe, however some of the commands issued are suitable only for PowerShell. Specifically, the first command issued in the terminal is cmd /C "path\to\python.exe path\to\launcher <arguments>" (which launches the debugging session), however immediately after the script exits the extension issues the command & path\to\virtualenv\Scripts\Activate.ps1.

It looks like the debugger tries to use the automation shell, instead of the integrated one.

@karthiknadig
Copy link
Member

If this is causing issue then, I recommend turning activations off and launch vscode from an activated environment.

As for the issue itself, the debugger does not select the type of shell it runs it. This is done by VSCode, python extension or debugger are not involved in this.

@mbikovitsky
Copy link
Author

Could the Python extension at least detect what kind of shell it runs in?

@karthiknadig
Copy link
Member

In the case of the debugger extension is not involved (at least directly). The debugger gives the command it expects VS Code to run via runInTerminal request. VS Code decides which terminal shell to use, and sends the command to that. On the extension side we expect this to use the terminal and shell as provided by the terminal.integrated.shell.windows setting. Why the debugger is being launched using automationShell is something we need to investigate further.

Then there is the issue of activation itself. Sending command to the terminal, currently this results in a race where command that gets sent first to the terminal determines if the environment is activated or not. This means sometimes the activation command is sent after the debugger command.

We have a bunch of items to improve terminal experience, #8907, #4568

@karthiknadig
Copy link
Member

Closing this since we are already tracking terminal experience bugs via #8907, #4568

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

2 participants