metals-vscode
metals-vscode copied to clipboard
Debugging: Evaluation failed because the thread is not suspended
Describe the bug
Unable to provide user input via the debug console input (stdIn) to a scala program during a debugging session
To Reproduce Steps to reproduce the behavior:
- Create a simple scala program that reads from stdin
- create debug profile in vscode with the metals extension installed
- Start a debug session
- Input text into debugging console
- See error
Expected behavior
I would expect the input to be passed along stdIn to the program, but instead vscode's debugging console is hijacking it and it never reaches my program.
Screenshots
Installation:
- Operating system: Linux
- VSCode version: 1.46.1
- VSCode extension version: v1.9.1
- Metals version: 0.9.1
Additional context
Looking at the vscode java debugger documentation I see a similar issue under their troubleshooting guide. Which might point to the root cause. I realize this is a separate extension but I figured this might help?
From what I can gather the extension needs the ability to use the integratedConsole (or an external one) rather than the default internalConsole which does not support input streams
Reason 2: you take the VS Code DEBUG CONSOLE view for program input by mistake. DEBUG CONSOLE only accepts input for evaluation, not for program console input.
For Reason 2, try to change the console option in the launch.json to externalTerminal or integratedTerminal. This is the official solution for program console input.
Source: official vscode java debugger troubleshooting guide
console - The specified console to launch the program. If not specified, use the console specified by the java.debug.settings.console user setting.
internalConsole - VS Code debug console (input stream not supported).
integratedTerminal - VS Code Integrated Terminal.
externalTerminal - External terminal that can be configured in user settings.
Source: official vscode java debugger docs
Search terms
stdin debug console thread suspended
Thanks for reporting and the great research! I can confirm that this is an issue currently.
I did dig around a bit and it seems that using integratedTerminal
is not a solution for us currently. VS Code will launch a program inside the integrated terminal only if we launch a program via the extension. The way we run programs currently is via Bloop, which provides us with an URI to connect to, which currently only works with the internal debug console.
I am afraid that fixing this issue currently might be quite complicated.
We should explore the options around attaching to running process via Bloop (or other means), which would in essence enable us to run a program and attach to it later.
I'm new to vscode & metals and came across this issue today.
Curious what folks are doing as a workaround... just launching the app from outside vscode?
@jbburns either run it using your build tool (sbt, mill, maven, gradle) or you can use Bloop CLI (https://scalacenter.github.io/bloop/setup), which will reuse the same compilation as Metals.
Personally, I recommend Bloop, which you can also use to watch the files and rerun on any changes. You can run it easily in the integrated terminal.