Shopify / Shopify/ruby-lsp

Feature Request: Support Interactive Debugging for Scripts Requiring User Input

Open
#3,735 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement pinned
Dominant language
Ruby
Stars
2k
Forks
281
Avg merge
2h 14m
Merged PRs (30d)
6

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the ruby-lsp launch flow with the referenced src/extension.ts launchOnConsole and launchOnTerminal implementations in the rdbg extension. Review how launch.json options are handled and investigate whether ruby/debug can support terminal I/O. Done means a documented option starts the debugged script in the integrated terminal while preserving debugging.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, vscode
Domain
developer-experience, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.