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

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)

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",
},
]

Debug azure function 1.0 in vscode?

What is the proper way to use the azure function core tools and debug a V1 nodejs function locally using visual studio code?
For a new V2 function everything works great. I cannot update to V2 functions however. The build process is out of my control and attempting to do so broke the build.
The project started with:
"azure-functions-cli": "1.0.0-beta.94",
I couldn't get that to work and upgraded to:
"azure-functions-core-tools": "^1.0.20",
I cannot update to the latest 2.x version because I get errors. Initially:
Microsoft.Azure.WebJobs.Script: The host.json file is missing the required 'version' property. See https://aka.ms/functions-hostjson for steps to migrate the configuration file.
Trying just adding the version (either 1.0 or 2.0) didn't work.
So back to 1.0.20. I run it and I see this:
Debugger listening on [::]:5858
That's great because it matches my launch config:
{
"name": "Crazy attempt",
"type": "node",
"request": "attach",
"port": 5858,
},
Actually I can attach and it seems to work. My breakpoints look good, and changes to my code appear without restarting the function host. However, none of my breakpoints get hit. When I kill the function host the debugger quits in my vscode window. I know I have to be doing something wrong, but I don't know what it is...
I had to start with this:
func host start --debug VSCode

VS Code opens a new debug console every time I build/run

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.

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}"
}

Stop a gulp watch task?

How do I stop a running gulp watch task without having to completely exit the program?
I can see the task running on the task bar bottom left with a spinning "slashes" character.
There appears to be a command "Terminate running task" (that can optionally be bound to a keyboard short-cut) - but executing this command doesn't seem to do anything and the task continues to run. Is this feature not implemented yet in the current preview version (0.1.0)?
In case others run across this question, open the Command Palette (Ctrl+Shift+P on Windows, Command+Shift+P on OSX, and search for "Terminate Running Task."
If you ever wonder what
search for "Terminate Running Task."
does behind the scenes: "workbench.action.tasks.terminate".
so you can just bind it, like this:
{ "key": "ctrl+shift+t", "command": "workbench.action.tasks.terminate" }
I was facing this issue from 2-3 months. Today I just opened tasks.json and saw hint that isWatching is deprecated instead use isBackground. I changed it and ran the task and terminated ,Voila it's working.
In short- Open tasks.json. If you see isWatching property on task change it to isBackground.