Skip to content

First Run in Terminal sometimes doesn't start python REPL or wait for it to finish starting #22691

@starball5

Description

@starball5

Behaviour

Expected vs. Actual

When no Python terminal created by the "Python: Run in Terminal" is currently open, running "Python: Run in Terminal" creates a new Terminal named "Python", and (tries to) start a Python interpreter to run the selected Python code in.

I expect the Python interpreter to finish starting up, and the first selected / smart-sent line to be given to the Python interpreter.

Instead, sometimes the first selected / smart-sent line becomes appended to the command that's supposed to start up the Python interpreter, resulting in an invalid command sent to the system shell. Sometimes even the first selected / smart-sent line is passed alone to the system shell before the command to start the Python interpreter has been run, and then the command to start the Python interpreter is run immediately afterward.

Steps to reproduce:

I cannot reproduce this reliably. Sometimes it starts up just fine, and sometimes I observe one of the two wrong behaviours.

I've tried using different combinations of the terminal.integrated.shellIntegration.enabled, python.terminal.activateEnvInCurrentTerminal, and python.terminal.activateEnvironment settings, but they don't seem to make a difference.

I'm on VS Code 1.85.1 on Ubuntu 22.04.2. I have v2023.23.13541005 of this Python extension installed.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.12
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
  • Value of the python.languageServer setting: Pylance
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2023-12-22 22:14:01.084 [info] Send text to terminal: /bin/python3
2023-12-22 22:14:01.969 [info] Send text to terminal: a=1
b=2
c=3

Which looks fine, but my shell receives /bin/python3a=1, gives an error message for it, then receives b=2 and c=3. It's not supposed to receive any of that (it's supposed to go to the Python interpreter, which failed to start due to the bad command).

User Settings


languageServer: "Pylance"

testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true

terminal
• activateEnvironment: true (also happens when set to false)

Metadata

Metadata

Assignees

Labels

area-replbugIssue identified by VS Code Team member as probable bugtriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions