Skip to content

Feature Request: Support Interactive Debugging for Scripts Requiring User InputΒ #3735

@jcouball

Description

@jcouball

I have checked that this feature is not already implemented

  • This feature does not exist

Use case

When developing and debugging command-line interface (CLI) applications or any Ruby script that requires user interaction (e.g., via gets), it would be helpful to be able to provide input during a debugging session.

Currently, when debugging a script with the ruby-lsp extension using the default launch configuration "Debug script", the script's standard output is directed to the VS Code DEBUG CONSOLE. However, the DEBUG CONSOLE does not accept standard input. This means that when the script execution reaches a line that waits for user input, the program hangs indefinitely. The developer cannot provide the necessary input, and the only option is to stop the debugger.

This limitation makes it impossible to use the ruby-lsp extension to debug any code path that follows an interactive prompt.

Supporting interactive debugging would provide a complete debugging experience within the ruby-lsp extension, allowing developers to efficiently debug all types of Ruby scripts, including interactive ones.

Description

I propose the addition of a new launch configuration option in launch.json that allows the debugged script to use the VS Code integrated terminal for its standard input, output, and error streams.

When this option is enabled, running a debug session would launch the script in the integrated terminal instead of attaching it solely to the DEBUG CONSOLE. This would allow the developer to type directly into the terminal to provide input when the script prompts for it, enabling the debugging session to continue past the input statement. This behavior would be analogous to the useTerminal option available in the rdbg VS Code extension.

Implementation

A potential implementation path could be to duplicate what the rdbg extension does: add a new boolean option to the launch.json debug configurations, for example, "useTerminal": true.

When this option is present and set to true, the extension would alter its launch sequence to spawn the debug process within the context of the VS Code integrated terminal. The implementation in the rdbg extension, which differentiates between a launchOnConsole and a launchOnTerminal method, could serve as a reference for how to implement this feature.

An alternative might be to investigate a solution within ruby/debug itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpinnedThis issue or pull request is pinned and won't be marked as stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions