question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Tyriarcommented, Jun 15, 2018

The terminal is working as expected to me. The text is being sent to the terminal just fine, that’s why the “Bad passphrase” line appears. Also there isn’t really a way to “fix” this upstream. The fix is either getting rid of the login or logging in automatically.

1reaction
DonJayamannecommented, Jun 7, 2018

The experiment with one.py failed in the same way as my debugging scenario.

Ok, great this means it has nothing to do with the extension.

This is similar to issues we have in other places (@brettcannon similar to PS terminal activation). The problem is the text is being sent to the terminal, but its not yet ready to accept input (e.g. accept the input for python one.py command).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Terminal launch failures - Visual Studio Code
Test your shell directly. Try running your designated integrated terminal shell outside VS Code from an external terminal or command prompt. Some terminal...
Read more >
Remote Development Tips and Tricks - Visual Studio Code
Run one of the following commands, in a local terminal window replacing user and host name as appropriate to copy your local public...
Read more >
Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >
Advanced Terminal Usage in Visual Studio Code
enablePersistentSessions to false , and the amount of scrollback restored is controlled by the terminal.integrated.persistentSessionScrollback setting.
Read more >
Integrated Terminal in Visual Studio Code
Visual Studio Code has an integrated terminal to enable working in your shell of ... the following .vscode/tasks.json file will launch a Command...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found