VS Code stuck in a "false" debugging state after interactive prompts when terminal launches
See original GitHub issueEnvironment 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)
- 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"],
- 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
- Open a
.py
file in VS Code, select thePython: 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 (View
→Output
, 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:
- Created 5 years ago
- Comments:6 (1 by maintainers)
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.
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).