Skip to content

VS Code stuck in a "false" debugging state after interactive prompts when terminal launches #1857

@alexvy86

Description

@alexvy86

Environment data

  • VS Code version: 1.23.1
  • Extension version: 2018.4.0
  • OS and version: Windows 10
  • Python version: 3.6.5, standalone install
  • Type of virtual environment used: virtualenv (through pipenv)
  • Relevant/affected Python packages and their versions: N/A

Actual behavior

When I start debugging a Python file with the Python: Current File configuration, if the integrated terminal prompts for user input when it launches, the python file does not run after the user finishes replying to the prompts, but VS Code seems to think debugging is in progress (the animated line in the Debug sidebar, right below the debug configuration dropdown, keeps moving). Neither Stop Debugging nor Restart Debugging from the Debug menu do anything once VS Code gets into this state. Closing that instance of the integrate terminal doesn't help either. The only way I found to go back to normal is closing and re-opening the VS Code window.

Further details
My integrated terminal (Git Bash in Windows) is configured such that it starts as an interactive login shell so the ~/.profile script is executed, In the script I check if my SSH key has been loaded into sshagent and prompt for the passphrase if it hasn't.

Expected behavior

The python file gets executed after the user finishes replying to any prompts initiated by the terminal when it launches. If that's not possible, then I expect VS Code to not get stuck in a "false" debugging state.

Steps to reproduce:

(Assumes you have at least one SSH key in your home folder, protected with a passphrase)

  1. Set your integrated terminal to launch an interactive login terminal by adding this to VS Code's User Settings (adjust path if needed):
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"terminal.integrated.shellArgs.windows": ["-l"],
  1. Create a .profile file in your home folder (e.g. C:\Users\<your-username>) or wherever your HOME environment variable (inside Bash) points to, and write this in it:
env=~/.ssh/agent.env

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
    (umask 077; ssh-agent >| "$env")
    . "$env" >| /dev/null ; }

agent_load_env

# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)

# Adding 12 hrs
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
    agent_start
    ssh-add -t 43200
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
    ssh-add -t 43200
fi

unset env
  1. Open a .py file in VS Code, select the Python: Current File debug configuration and start debugging.

You'll be prompted for the private key passphrase, but once you provide it nothing else happens, the terminal just sits there and you can use it normally to execute other commands. However, VS Code thinks debugging is in progress and cannot be made to think otherwise without restarting it.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

##########Linting Output - pylint##########
No config file found, using default configuration
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

[Empty]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-terminalbugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions