Skip to content

Debugger: support command + file launch config with program fallback and default file behavior#4051

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-debugger-file-path-spaces-again
Open

Debugger: support command + file launch config with program fallback and default file behavior#4051
Copilot wants to merge 2 commits intomainfrom
copilot/fix-debugger-file-path-spaces-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Motivation

Debugger launch fails when workspace/file paths contain spaces because the previous default config built a single unquoted program string (for example, ruby ${file}), which gets split by the shell.
This change addresses that path-tokenization failure while preserving compatibility with existing program-based launch configs.

Implementation

  • Config shape update (Option B)

    • Added first-class command + file launch configuration support.
    • Kept program as a backward-compatible fallback.
  • Defaulting behavior

    • file now defaults to ${file} during config resolution when:
      • command is present
      • program is absent
      • file is omitted
    • This keeps script configs minimal while allowing explicit ${relativeFile} where needed.
  • Generated debugger templates/docs

    • Debug script now emits only:
      { "type": "ruby_lsp", "name": "Debug script", "request": "launch", "command": "ruby" }
    • Debug test emits explicit relative file:
      {
        "type": "ruby_lsp",
        "name": "Debug test",
        "request": "launch",
        "command": "ruby -Itest",
        "file": "${relativeFile}"
      }
  • Launch command construction hardening

    • When using command + file, the extension constructs program with quoting/escaping for the file argument.

Automated Tests

Updated debugger unit/integration tests to:

  • assert new default config output (command-first shape),
  • assert file defaults to ${file} when omitted,
  • exercise launch flow with a temp path containing spaces,
  • verify file: "${file}" is exercised by opening the target file as the active editor before launching debug.

Manual Tests

  1. Open a project in a path containing spaces.
  2. Generate launch.json via “Debug: Add configuration...”.
  3. Run Debug script:
    • verify config can omit file and still launches current file.
  4. Run Debug test:
    • verify explicit ${relativeFile} flow still launches correctly.
  5. Confirm an older config using:
    { "type": "ruby_lsp", "request": "launch", "program": "ruby ${file}" }
    still resolves through the legacy program path.
  6. Confirm ${file} behavior:
    • open a Ruby file in the editor so it is the active file,
    • launch with:
      { "type": "ruby_lsp", "request": "launch", "command": "ruby", "file": "${file}" }
    • verify the debugger launches that active file.

Copilot AI changed the title [WIP] Fix debugger fails when file path contains spaces Debugger: support command + file launch config with program fallback and default file behavior Apr 8, 2026
Copilot AI requested a review from rafaelfranca April 8, 2026 13:16
@rafaelfranca rafaelfranca force-pushed the copilot/fix-debugger-file-path-spaces-again branch from 6b91f2e to f8af8f7 Compare April 8, 2026 13:38
@rafaelfranca rafaelfranca added bugfix This PR will fix an existing bug vscode This pull request should be included in the VS Code extension's release notes labels Apr 8, 2026
@rafaelfranca rafaelfranca force-pushed the copilot/fix-debugger-file-path-spaces-again branch from f8af8f7 to 273d920 Compare April 8, 2026 13:42
@rafaelfranca rafaelfranca marked this pull request as ready for review April 8, 2026 13:42
@rafaelfranca rafaelfranca requested a review from a team as a code owner April 8, 2026 13:42
@rafaelfranca rafaelfranca removed their request for review April 8, 2026 13:42
@rafaelfranca rafaelfranca force-pushed the copilot/fix-debugger-file-path-spaces-again branch from 273d920 to 2bd8754 Compare April 8, 2026 16:01
@afurm
Copy link
Copy Markdown

afurm commented Apr 13, 2026

When file is ${file} (VS Code's template variable for the active file), quoteForShell escapes it to "\${file}", which prevents shell expansion — but the real concern is whether VS Code substitutes ${file} before this function is called, or if the escaped literal string reaches the shell. Can you verify the substitution order: does VS Code resolve ${file} before program is passed to the rdbg --command invocation?

@rafaelfranca
Copy link
Copy Markdown
Member

@copilot can you add a test making sure the ${file} value for the file debug configuration is correctly expanded. If not, can you fix the problem?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 14, 2026

@copilot can you add a test making sure the ${file} value for the file debug configuration is correctly expanded. If not, can you fix the problem?

Added in 5063240. I updated the debugger launch test to open test.rb as the active editor and then start debugging with file: "${file}", so the test now exercises the ${file} expansion path directly (including a workspace path with spaces).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • update.code.visualstudio.com
    • Triggering command: /opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node ./out/test/runTest.js --grep Debugger (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This PR will fix an existing bug vscode This pull request should be included in the VS Code extension's release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debugger fails when file path contains spaces (all platforms)

4 participants