You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"The terminal process terminated with exit code: 1" on Windows when running CLI apps in the terminal #2750
import'dart:io';
voidmain() {
print('How old are you?');
String age = stdin.readLineSync();
print('You have $age age');
}
When I run it using cmd, it fires up normally, ie it prints the first print, gets the keyboard input, and prints the second print. When I run it with VS Code, the script prints the first print and then reads the keyboard data in a loop, it doesn't go to the second print.
I fixed it by configuring launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Dart",
"program": "${file}",
"request": "launch",
"type": "dart",
"console": "terminal"
}
]
}
I added "console": "terminal".
Now the program starts, but as soon as the program finishes, the terminal crashes and gets an error:
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" terminated with exit code: 1.
The same thing happens with cmd:
The terminal process "C:\WINDOWS\System32\cmd.exe" terminated with exit code: 1.
What can I do to make the program run after clicking F5, execute correctly and not to turn off the terminal immediately after executing the program?
changed the title [-]Problem with debug console and stdin[/-][+]"The terminal process terminated with exit code: 1" on Windows when running CLI apps in the terminal[/+]on Aug 31, 2020
After much debugging, I've managed to track down what's happening here. When we ask VS Code to run the process in the terminal, we collect the process ID in case we need to terminate it (for example if you click Stop on the debug toolbar):
We fall back to the shell ID if it doesn't give us the process ID. Then when the app finishes in the shell, VS Code asks us to terminate and we end up terminating the shell. I'm guessing on macOS we end up with the real process ID (or, terminating the shell doesn't get reported as an error in this way).
I have some ideas about how to fix, I'll do some testing. Thanks!
Activity
DanTup commentedon Aug 31, 2020
Thanks - I'm able to reproduce this on Windows.
[-]Problem with debug console and stdin[/-][+]"The terminal process terminated with exit code: 1" on Windows when running CLI apps in the terminal[/+]DanTup commentedon Aug 31, 2020
After much debugging, I've managed to track down what's happening here. When we ask VS Code to run the process in the terminal, we collect the process ID in case we need to terminate it (for example if you click Stop on the debug toolbar):
We fall back to the shell ID if it doesn't give us the process ID. Then when the app finishes in the shell, VS Code asks us to terminate and we end up terminating the shell. I'm guessing on macOS we end up with the real process ID (or, terminating the shell doesn't get reported as an error in this way).
I have some ideas about how to fix, I'll do some testing. Thanks!
DanTup commentedon Aug 31, 2020
There's a new beta version at https://github.com/Dart-Code/Dart-Code/releases/tag/v3.14.0-beta.2 if you want to try it out. If you install the beta, you'll be automatically migrating back to stable releases once it goes out.
Thanks!
piechowiakmichal commentedon Aug 31, 2020
Everything works correctly. I tested using Powershell and CMD as default console in VS Code.
Thank you for helping me so quickly!
DanTup commentedon Sep 1, 2020
Great, thanks for confirming (and reporting)!