VS Code opens a new debug console every time I build/run - visual-studio-code

Every time I build or run a program in VSCode a new python debug console is loaded. Before I know it I have 20+ and need to start deleting them. After 32 open consoles I get the error "The terminal process terminated with exit code: 256". I changed the terminal from the default console to git bash recently. How can I stop this?

A way around this issue is to stop VS Code from redundantly printing to the TERMINAL during debugging in the first place. Since it prints to the DEBUG CONSOLE as well, you can use that instead.
Change console to "none" "internalConsole" in each configuration in your project's launch.json file:
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole"
}
]
May 2019 Update: the "none" option was replaced by "internalConsole" so I edited my answer to reflect that. Here's the relevant GitHub Issue.

Adding "args": ["&&", "exit"], to launch.json remedies this for Git Bash. Certainly a hack, but I no longer have to manually close many debug terminals.

This may have been resolved in recent debug updates to core VS Code within the last year (as of 8/2022), but I was still seeing this intermittently.
I don't know if this will help the original poster, but I discovered that for me the issue persisted due to using Git Bash as the default terminal in Windows. Switching to Command Prompt as the default terminal fixed the issue. I haven't tested with other platforms or terminals.
Changing the default terminal to Command Prompt causes the Python extension to launch the "Python Debug" terminal with Command Prompt instead of Git Bash. I did log a VS Code/Python Extension defect about this. The initial response is that Git Bash is not officially supported currently.
There appears to be a communication problem between the Git Bash terminals and VS Code that causes this issue. Some of the characters between Git Bash and VS Code get dropped. Sometimes this mangles the debug command and I get and error and have to retry in addition to getting an extra debug window.
There is some additional background info and hacks to fix this from the past in this answer.

Hopefully fixed in the Insiders Build and should be in v1.54. See Debug opens a new integrated terminal for each Python session
. Test it in the Insiders Build if you can and report at the issue if it fixed/did not fix.

Actually you can delete all the instances of the terminal just by clicking on the trash can icon 🗑. If it does not work for the first time, restart the VS Code and try again.

Related

vscode debugger does not launch debug console

I am so frustrated that my vscode debugger does not work on the remote servers suddenly today.
Here is the situation.
When I use the starred interpreter by vscode (the recommended one), it works smoothly. However, when I want to use other interpreters, the ones stored in personal folder on the server, the debugger doesn't launch a debug console and dose not enter the file.
Vscode can find and recognize the interpreters and I can use those interpreters to run scripts but can NOT DEBUG.(on the remote server) However, it works fine on my local machine with multiple python interpreter.
Can anyone give me some help? I have tried uninstall vscode completely on my end but still not work. Thank you so much!!
The Python extension debugger in VSCode requires a minimum Python version to run properly. However, this is not documented at all in the changelog at https://github.com/microsoft/vscode-python/releases, but you have to find out for yourself. For example, at the time of writing, version 2022.12.0 doesn't harmonize with Python 3.6.8.
As a workaround you have 2 options
Upgrade your interpreter to a newer version
Downgrade the Python extension to an older version
For the latter, go to the extensions page and under the Uninstall button you will find Install another version.... This makes it easy to try out what works best for you.
Just in case stumbles upon this question and the accepted answer doesn't work for you:
Try downgrading the Python extension version in VSCode. That fixed the issue for me. I picked a random version from ~2 months ago (when I wasn't having the issue). You might need to try a few versions though.
This workaround might work for you: use the interpreter that works for you but in the launch.json configuration file add a
"python": "/path/to/the/python/you/want",
I share the same experience. It seems that vscode fails to start the remote debugger with the interpreter I want but succeeds with the system interpreter.
For example:
"configurations": [
{
"name": "config_name",
"type": "python",
"python": "/path/to/desired/python",
"request": "launch",
"program": "/path/to/python/script.py",
"console": "integratedTerminal",
},
]

prevent VS code notification: 'launch' is already running. Do you want to start another instance?

I'm writing an ui with tkinter (ttk), and if I run the my program while an other instance of the ui is open, VS code (starting today) started giving a (error) notification which looks like this:
I'm not sure but I think this started happening when I started using ttk (instead of only tkinter).
I know you're not meant to run multiple instances of your program, but while coding it's very convenient to be able to see what you're changing along the way, and not have to close your previous instance.
Is there a way to stop this notification of appearing?
Is there a way to stop this notification of appearing?
VSCode 1.71 (August 2022) should offer an option for that.
See issue 147912 and PR 147914
Add new launch config debug option for silent '{0}' is already running. Do you want to start another instance? confirm dialog.
Tested with simple launch config:
{
"command": "npm start",
"name": "Run npm start",
"request": "launch",
"type": "node-terminal",
"suppressMultipleSessionWarning": true
}
This is available in VSCode Insiders today.
I bound F5 to restart, so i only have to run it once, and to see changes i restart that instance (changed run to F7)

VSCode keeps opening powershell on start even though Git Bash is set as default

I have set my integrated default terminal in VSCode as Git Bash but whenever I launch VSCode, powershell pops up instead of bash. It does not, however, change the default terminal setting but it is irritating.
I have tried removing the profile of powershell from settings but that seems to do nothing.
Why is this happening?
Make sure you upgrade to vscode v1.60.1 - there is a fix in that point release for this issue.
See Select Default Profile do not actually open gitbash. After relaunch, on startup, it just keeps open PowerShell.
The same thing was happening to me and the referred to fix in the Insiders' Build 05/14/2021 did in fact fix it for me. In the meantime, opening another terminal does always open git bash for me - but that is a pain.
This worked for me:
{
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.profiles.windows": {
"PowerShell": null,
"Git Bash": {
"source": "Git Bash"
},
"Windows PowerShell": null
},
"terminal.integrated.automationShell.windows": "Git Bash",
"powershell.enableProfileLoading": false,
"powershell.integratedConsole.showOnStartup": false
}
I managed to find a workaround without using the Insider's Build that may work for some of you : I removed all profiles safe for the one I want, and reinstalled VS Code. Then it somehow started using the right terminal on startup. I don't know if this works without disabling all other profiles though.
I was still having this issue, and what worked for me was:
When PowerShell opened, I reset GitBash to my default, and then killed the terminal (so there were no terminal's running).
Removed the terminal panel from view by clicking the X in the top right
Closed VSCode
When I opened my codebase again and showed the terminal, it began working.
Just did an update to version 1.60.1
and it fixed it.
From the release notes the bug was addressed and has since been merged.
Update 1.60.1: The update addresses these issues
This looks like an ongoing issue that is still not fixed in the current version (1.60.0).
This is now fixed in my current version (1.61.1).

VSCode: Debug > Add Configuration, nothing happens

Using Visual Studio Code v 1.32.3 on Windows 10, when I navigate to Debug > Add Configuration, nothing happens. No errors or other messages, nothing appears to be written to the workspace folder, no errors in Event Viewer, so far just nothing.
I am somewhat new to VSCode so please don't discount that this might be a newbie error. Potentially notable is that the project is a Cordova project, I have created a Workspace (and confirmed that I am using it and not just opening the folder).
What I have checked so far:
Verifying that nothing is actively trying to build or otherwise access that folder. PhoneGap Desktop is stopped and no emulators running.
Restarted PC
Reinstalled the Cordova Tools plugin
Interestingly if I open a new instance of VS Code and before opening any file or folder I go back to Debug > Add Configuration I will get a message "Please first open a folder in order to do advanced debug configura..." So this indicates that there may be a problem with my workspace or directory but I haven't found it yet.
Any ideas greatly appreciated.
Edit 1:
Version of Cordova Tools is 1.8.0.
I've since tried adding my own launch.json to the .vscode directory. Contents:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run android on device|emulator",
"type": "cordova",
"request": "launch",
"platform": "android",
"target": "device|emulator",
"sourceMaps": true,
"cwd": "${workspaceFolder}"
},
]
}
Notable is that in the bottom right corner of the window a "Add Configuration" button appears while I am viewing launch.json and it does appear to work correctly, prompting me with snippets to add.
None of these impact my ability to debug unfortunately.
Alright I think I have this working. Steps:
I deleted the launch.json added in my edit. (Effectively now no launch.json file again)
Navigate to Debug > Start Debugging
Ignore the error dialog that appears
VSCode will create a launch.json and display the debug menu
From here it looks like I'm back on track.
Check VS Code OUTPUT window. When VS Code is downloading some launcher packages like .NET Core Launch, Debugging process may be affected.
After downloading packages are completed check it again.
ctrl + shift + P then enter "reload window" works for me
For me when I press Add Configuration from the dropdown on the upper left it does nothing, I keep pressing up and down in and out of places and suddently it works... then it does not again...
However I found a blue button on the lower right of the screen that works more consistently, I'm uncertain if it is the same issue or that button doesn't work for you either but this was my own experience.
Did you install the latest version of VS Code? I had the same problem and I fixed it by updating to the latest version.
One silly mistake that may lead to this problem is and that I did was to debug when in a non executable file, so be sure to be in that file which is executable. In my case it was a .cpp file where I should've been but I was in one of the header file .h that I created while debugging.
You should delete .vscode folder and run again debugger extension.
This will generate a new .vscode folder with a launch.json file in.

VSCode PowerShell 0.11.0 Debug Console is no longer used - How do I "correctly" use VSCode now?

I am still a relatively new PowerShell coder, and I have been successfully using the PowerShell extension v0.8.0 for Visual Studio Code. I could write a script, press F5, and happily see my output.
Today I noticed there was an upgrade to v0.11.0, so I clicked the install believing that newer = better.
Unfortunately, now whenever I press F5 to execute my script, I get this error:
"The Debug Console is no longer used for PowerShell debugging. Please
use the 'PowerShell Integrated Console' to execute commands in the
debugger. Run the 'PowerShell: Show Integrated Console' command to
open it."
I can't say I've been smart enough to learn more than basics, and never really knew how to use the debugger, but I was getting by. With this error, however, does this mean that every time I want to execute my script, I have to press CTRL+` and then type out things like I was at a console window? For now, I've found a workaround by clicking in the editor window and pressing CTRL+a, F8. I was hoping to start reading an article on debugging, but it seems like the extension update has rendered the material obsolete.
This seems like a huge step back in terms of usability, but I'm not sure if it's really a bug for the extension developer, or I'm just not skillfull enough to use the extension?
All that happens now is the output is to the powershell integrated terminal. So make sure that the Terminal tab is active. Then hitting F5 works as normal (before).
My launch.json looks like:
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch (current file)",
"script": "${file}",
"args": [],
"cwd": "${file}"
}