Stop a gulp watch task? - visual-studio-code

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.

Related

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)

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.

VS Code Terminal Not Allowing Typing

My VS code terminal was working fine, until one day when I tried to work on a project, that was still open in VS code, my terminal didn't allow me to type any commands. I couldn't type anything. This is the screen that I get.
Okay, for those of you struggling with the same problem, I've managed to solve it by clicking on the drop-down menu that says powershell and changing it to cmd.
this happened to me and simply
close vs code
right click on it
run as administrator
open the terminal and it will work
this problem happened when I changed the default path of CMD
For me, I tried using Powershell/CMD/Bash and I was having errors/blank terminal. I found typing echo hello and pressing CTRL + C made it appear. So in fact, everything was working, my terminal was just blank/glitched out, but was really accepting input.
I had a similar issue when running ionic serve command which runs the development server on the localhost. I paid attention after executing the command above, and it said:
Use Ctrl+C to quit this process
Pressing Ctrl+C then displays:
Terminate batch job (Y/N)?
Type Y or y
then the command prompt is shown again!
Here is a sample terminal window - trimmed for brevity:
For who has this problem using React. This happens when you start a live version using npm start. The terminal that handles the live version of the app cannot be used for anything else.
So to continue using the terminal you need to open a new terminal to use in parallel. To do so just click on the plus icon in the top right corner of the terminal panel then choose the "Power Shell" option. This will open a new terminal without restarting visual studio.
In Mac, when working with Python, this helped me: instead of clicking on the "Run Code" option, click on "Run Python file", in the right corner.
For Ubuntu users this is solved by this solution:
File -> Preferences -> Setting -> Features -> Terminal -> Inherit Env
I found two vscode on my desktop, I opened the other one and it worked. Looks like I updated it but the older one didn't disappear.
If typing Ctrl+C can help to get out of this frozen state, that will be easier to do with VSCode 1.64 (Jan. 2022)
The terminal can type the answer for you.
Terminal -- Auto-reply
The terminal is now able to automatically reply when a specific sequences of characters is received.
A good example of where this is useful, which is also the only default case, is the Windows batch script message Terminate batch job (Y/N)? after hitting Ctrl+C when running a batch script.
This typically just ends up causing problems for the user.
The terminal will now automatically reply with Y and enter (\r) which makes Ctrl+C in Windows feel much better.
Pressing Ctrl+C will immediately reply to the question and return to the prompt:
Theme: Sapphire
The feature was made generically so you can setup custom replies for other thing, just be careful when doing this as you are sending text to the process automatically.
For example you could use it to automatically update Oh My Zsh when prompted:
"terminal.integrated.autoReplies": {
"[Oh My Zsh] Would you like to check for updates? [Y/n]": "Y\r"
}
If you use Clink and enable their similar feature, you can disable it in Clink or in VS Code by setting the reply to null to avoid the two features conflicting with each other:
"terminal.integrated.autoReplies": {
"Terminate batch job (Y/N)": null
}
Go to terminal, preferences, settings.
Check "run code in terminal"
Restart VS.
I changed from bash to powershell in terminal first but the command prompt still not shown.
Then I navigate to File -> Perferences -> Settings and it starts working (command prompt shown)
This seems to just be a display problem. It happened to me when I changed my display settings for desktop icon and app scaling settings.
I managed to fix the problem by simply restarting my computer and re-opening VS code
I had the same problem ... In my case just run vs-code as administrator and works

Whenever I open integrated terminal in VS code 1.18, it crashes PowerShell

Even though I have set below code in setting.json:
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
Whenever I open the "integrated terminal" it starts and right away shows:
"The terminal process terminated with exit code: 259"
There is also a dialog outside code saying:
"powershell has stopped working
A problem caused the program to stop working correctly.
Windows will close the program and notify you if a solution is available."
this happens in 32bit and 64bit too
Any idea how to overcome this?
The code 259 usually means STILL_ACTIVE and this is rather strange.
You may try to use ProcessMonitor to determine which processes are started during your call and perhaps that gives you a clue.
Open Task Manager
I Clicked on End Task on all process of VS Code
Error vanished

Aborting an "unclosed" powershell command in Visual Studio Nuget Package manager console

I accidently issued an invalid PowerShell command in the NuGet Package Manager console and locked the console.
The command was
PM> Get-Project -all | Where { $_.ProjectName -imatch "GPEC.Personne }
then the console displayed >> as prompt and I was unable to leave this mode. Closing and reopening the console did not help. (Had to restart VS).
Is there a way to gracefully cancel a wrong command in this case and return to the standard PM> prompt?
Thanks in advance.
Philippe
That appears to be buggy behavior. The >> indicates that syntactically the current command isn't finished. That is, you have opened a double quoted string but haven't finished it. Press the "Clear Console" toolbar button to escape out of this mode.
In the VS console window there's a "Stop Command Execution" button (a red square if enabled). It's next to the "Clear Console" button. The button is only enabled if a command is actually running.
Based on the accepted answer, it seems OP didn't actually need to abort an executing command. But this answer should prove useful to anyone who really does need to abort a command.
It's a simple question, that's already been answered but I think I might have something to add. In terms of clarifying the behavior of the Nuget Console.
This happens when you open a statement with a single/double quotation and don't close it properly or don't close it at all.
Example (Respectively)
Add-Migraion "Add 'Employee' Model'
OR
Add-Migraion "Add 'Employee' Model
The console will assume that you need to break the command into two lines so it will wait for you to finish the command or close the statement on another line by showing this symbol >>. In such case if that happened by mistake all you have to do is type " or ' based on how you opened the statement.
Sometimes you can look in the regular Windows task manager and kill the task. Can be difficult to find though.
I cringe just posting this.
There's a Debuggable Package Manager program installed with Visual Studio (not sure which version this began with).
You will need to manually CD to the correct folder for your project, but it can be more reliable for certain tasks and you can open multiple windows too which can be nice.
And yes - CTRL+C works to terminate the task :-)