rubyide / vscode-ruby

Provides Ruby language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby
MIT License
1.26k stars 285 forks source link

rdebug-ide Exits with Invalid char '\x7F' in expression #643

Closed LarryNorth closed 4 years ago

LarryNorth commented 4 years ago

Your environment

VSCode Ruby: 0.27.0 Ruby: 2.7.1 VS Code: 1.47.3 with Remote - WSL: 0.44.4 Windows 10 Version 2004 WSL 2 with Ubuntu Version 20.04.04 LTS Docker Desktop Version 2.3.0.4 (46911), using WSL 2 based engine

Expected behavior

Run > Start Debugging runs the command

Actual behavior

app_1  | Fast Debugger (ruby-debug-ide 0.7.2, debase 0.2.4.1, file filtering is supported) listens on 0.0.0.0:1234
app_1  | Connected from local client
app_1  | 1: Starting control thread
app_1  | 1: Processing in control: start
app_1  | 1: Starting: running program script
app_1  | Uncaught exception: /bin/pwd:1: Invalid char `\x7F' in expression
app_1  | /bin/pwd:1: Invalid char `\x02' in expression
app_1  | /bin/pwd:1: Invalid char `\x01' in expression
app_1  | /bin/pwd:1: Invalid char `\x01' in expression
app_1  |        /usr/local/bundle/bin/rdebug-ide:23:in `load'
app_1  |        /usr/local/bundle/bin/rdebug-ide:23:in `<main>'
app_1  | /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:106:in `debug_load': /bin/pwd:1: Invalid char `\\x7F' in expression (SyntaxError)
app_1  | /bin/pwd:1: Invalid char `\\x02' in expression
app_1  | /bin/pwd:1: Invalid char `\\x01' in expression
app_1  | /bin/pwd:1: Invalid char `\\x01' in expression
app_1  |        from /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:106:in `debug_program'
app_1  |        from /usr/local/bundle/gems/ruby-debug-ide-0.7.2/bin/rdebug-ide:193:in `<top (required)>'
app_1  |        from /usr/local/bundle/bin/rdebug-ide:23:in `load'
app_1  |        from /usr/local/bundle/bin/rdebug-ide:23:in `<main>'
rdebug-ide_app_1 exited with code 1

I've used rdebug-ide successfully with a simple Rack app and a simple Rails app, but found it to fail with a complex Roda/Opal app (https://github.com/Rails-18xx/Rails). I am able to demonstrate the error above in the bare-bones, do-nothing app below. Sorry if I'm missing something obvious.


Gemfile:

source 'https://rubygems.org'

ruby '2.7.1'

gem 'debase'
gem 'ruby-debug-ide'

Dockerfile

FROM ruby:2.7.1-buster

COPY . /app

WORKDIR /app

RUN bundle install

docker-compose.yml

version: '3.5'

services: 
    app: 
        build: .
        ports: 
            - 1234:1234
            - 21612:21612
        command: rdebug-ide -d --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- /bin/pwd

       # this command works
       # command: /bin/pwd

.vscode/launch.json

{
"version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for rdebug-ide",
            "type": "Ruby",
            "request": "attach",
            "remoteHost": "127.0.0.1",
            "remotePort": "1234",
            "remoteWorkspaceRoot": "/app",
            "cwd": "${workspaceRoot}"
        }
    ]
}
LarryNorth commented 4 years ago

The problem also occurs when running locally on Windows 10:

VSCode Ruby: 0.27.0 Ruby: 2.7.1 VS Code: 1.47.3 Windows 10 Version 2004 Docker Desktop Version 2.3.0.4 (46911)

LarryNorth commented 4 years ago

Apparently the command run by rdebug-ide must be from the Ruby ecosystem. Using bundle to execute the target command works:

command: rdebug-ide --host 0.0.0.0 --port 1234 --dispatcher-port 26162 -- /usr/local/bin/bundle exec /bin/pwd

Explanations welcome.