Vscode-ruby: ruby debug functionality is not working

Created on 22 Mar 2017  Â·  20Comments  Â·  Source: rubyide/vscode-ruby

Your environment

  • vscode-ruby version: 0.10.4
  • Ruby version: ruby 2.3.3p222
  • VS Code version: 1.10.2
  • Operating System: Window 7 64bit
  • Hardware (optional):

Expected behavior

open debugger view, then pop up select environment.
after ruby chosen, debug the local file should start.

Actual behavior

after ruby chosen, nothing happened, and no output for extensions.

Steps to reproduce the problem

  1. install ruby and the extension, and follow the details in extension page.
  2. open debugger view, then pop up select environment, finally choose ruby.
question

Most helpful comment

Hi there,
apparently same issue here. Trying to run rails server (debug) or attach to a debug console session fail. (It worked like 1 month ago)

My env

Version: 1.32.1
Commit: 05f146c7a8f7f78e80261aa3b2a2e642586f9eb3
Date: 2019-03-08T00:46:10.898Z
Electron: 3.1.3
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Linux x64 4.8.0-36-generic
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
ruby extension : 0.22.3
* LOCAL GEMS
debase (0.2.2)
debase-ruby_core_source (0.10.3)
LOCAL GEMS *
ruby-debug-ide (0.6.1)

Launch.json

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

    {
        "name": "Rails server",
        "type": "Ruby",
        "request": "launch",
        "cwd": "${workspaceRoot}",
        "program": "${workspaceRoot}/bin/rails",
        "args": [
            "server"
        ]
    },
    {
        "name": "Listen for rdebug-ide",
        "type": "Ruby",
        "request": "attach",
        "cwd": "${workspaceRoot}",
        "remoteHost": "127.0.0.1",
        "remotePort": "1234",
        "remoteWorkspaceRoot": "${workspaceRoot}"
    },
]

}

Expected behavior

Rails server -> run a rails server and stop on breakpoints !
Listen for rdebug-ide -> attach to a rails console debug session

Actual behavior

Rails server does not launch. Only debug bar is displayed. Debug console is not automatically displayed
Only an 'Assertion failed' in OUTPUT console (Extensions).

Hope it'll help.

All 20 comments

Will you post your launch.json?

I am having the exact same problem. Originally I had Ruby 2.3.3 (x64) installed but then uninstalled and installed the version below.

Your environment

vscode-ruby version: 0.10.4
Ruby version: ruby 2.1.9p490
VS Code version: 1.11.2
Operating System: Window 10 64bit

Below is my launch.json
{
"version": "0.2.0",
"configurations": [

    {
        "name": "Debug Local",
        "type": "Ruby",
        "request": "launch",
        "program": "${workspaceRoot}/main.rb"
    }

    {
        "name": "Launch Extension",
        "type": "extensionHost",
        "request": "launch",
        "runtimeExecutable": "${execPath}",
        "args": [
            "--extensionDevelopmentPath=${workspaceRoot}"
        ],
        "sourceMaps": true,
        "stopOnEntry": false
    }
]

}

For me debugger stopped working too:
vs code : Version 1.12.1 (1.12.1)

{
"version": "0.2.0",
"configurations": [
{
"name": "test.rb",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "test.rb",
"args": [
"iPad Pro (9.7 inch)", "10.3"
]
}
]
}

Not sure if related...

Debugger works with hardcoded target, e.g. "program": "${workspaceRoot}/main.rb"

But if user doesn't know to call their file main.rb then there is no error or warning.

Also, "program": "${workspaceRoot}/{file}" silently fails.

Maybe you just made a typo. The program "${workspaceRoot}/${file}" should
work.

On Fri, 1 Sep 2017, 22:51 Steve Weil notifications@github.com wrote:

Not sure if related...

Debugger works with hardcoded target, e.g. "program":
"${workspaceRoot}/main.rb"

But if user doesn't know to call their file main.rb then there is no
error or warning.

Also, "program": "${workspaceRoot}/{file}" silently fails.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/rubyide/vscode-ruby/issues/129#issuecomment-326691380,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACQ6IM6DOEFb67y3sqtL7sTKnQpAtY4ks5seHxbgaJpZM4Mli6O
.

Thanks @raldred - I mistyped.
Here is a copy and paste from my launch.json:

    {
      "name": "Debug Local File: (current)",
      "type": "Ruby",
      "request": "launch",
      "stopOnEntry": true,
      "showDebuggerOutput": true,
      "cwd": "${workspaceRoot}",
      "program": "${workspaceRoot}/${file}"
    },

I get this in the Debug Console window, but nothing else. (And no debug toolbar with Continue, Step Over, etc.)

Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.2.beta10, file filtering is supported) listens on 127.0.0.1:1234

Specifying a complete file name works fine. (e.g. "program": "${workspaceRoot}/main.rb")

Closing for issue cleanup. Apologies if this is still an issue. We are working to improve the core extension experience.

did VSCode's core extension team figure this out? Or is it on the extension creator? Or is this fixed but I'm just having problems getting to work after hours of hunting down blogs with people claiming it works?

It somewhat depends on your setup right now. There are definitely issues with the debugger though.

How do you have the debugging gems installed?

@wingrunr21 well thanks for following up and what a great morning, because it works. Just for closure, here's my environment:
$gem list debase byebug ruby-debug-ide
* LOCAL GEMS *

debase (0.2.2)
debase-ruby_core_source (0.10.3)

* LOCAL GEMS *

byebug (10.0.2, 9.0.6)
pry-byebug (3.4.2)

* LOCAL GEMS *

ruby-debug-ide (0.6.1)

vscode version 1.26.1
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
rvm current ruby-2.5.1

And I have this configuration working - whatever file I have in open and in context, F5 will start debugger and hit breakpoints. Note when vscode created my launch.json, it ad // comments in it so I had to remove those..

         {
            "name": "Debug Local File",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${file}"
        },

Ok great! To be clear the gems are not installed via bundler and you are not using a gemset correct? I’m gathering information on people’s environments to see if I can figure out a better way to auto detect things.

correct, the related gems for this project are not installed via bundler. I do have this in my Gemfile though:
gem 'pry' gem 'rspec' gem 'simplecov' gem 'pry-byebug' gem 'pry-rescue' gem 'pry-rails'

My debugger stopped working recently:

launch.json:

"version": "0.2.0",
    "configurations": [
        {
            "name": "Rails server",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}/bin/rails",
            "args": [
                "server",
                "-p",
                "3000"
            ]
      }
]

Using puma as my web server - it's booting in single worker mode (typically run with multiple workers but not in development)

*** LOCAL GEMS ***

ruby-debug-ide (0.6.1)

*** LOCAL GEMS ***

debase (0.2.2)
debase-ruby_core_source (0.10.4)

Installed using the shell embedded into VScode - shouldn't make a difference but just to be safe

Not referenced in Gemfile and I don't use RVM so no gemsets.

Breakpoints are just ignored - like they aren't even there.

Same here, can't get it to work.
Any pointer to try and understand what could be the cause?

I couldn't get debugging to work with Puma until I set workers to 0 and threads to 1. In my case, threading/worker processes were causing issues.

Hi @bradleygolden, do you mind explaining a bit further how to set these parameters?

I am new to ruby/vscode and trying to debug an application which uses rake server (which uses Puma under the hood) and rake resque:workers.

I explain my problem further in https://github.com/rubyide/vscode-ruby/issues/448#issuecomment-469826604 https://github.com/rubyide/vscode-ruby/issues/448#issue-417458597

Any help would be very much appreciated :)

I'm not an expert when it comes to rails development. With that said, we have a puma.rb located in our application that looks like this:

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
#
# Best to have # workers match # of cores.
workers ENV.fetch("PUMA_WORKERS") { 2 }

# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup

# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
port        ENV.fetch("PORT") { 3000 }

# Specifies the `environment` that Puma will run in.
environment ENV.fetch("RAILS_ENV") { "development" }

on_worker_boot do
  ActiveRecord::Base.establish_connection
end

Setting environment variables PUMA_WORKERS=0 and RAILS_MAX_THREADS=1 worked for me to get debug working. I will say however this is not viable because our app now relies on multithreading which means I don't have a workable solution for my use case. If you can get away with using a single thread for local development this might do the trick for you.

Hi there,
apparently same issue here. Trying to run rails server (debug) or attach to a debug console session fail. (It worked like 1 month ago)

My env

Version: 1.32.1
Commit: 05f146c7a8f7f78e80261aa3b2a2e642586f9eb3
Date: 2019-03-08T00:46:10.898Z
Electron: 3.1.3
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Linux x64 4.8.0-36-generic
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
ruby extension : 0.22.3
* LOCAL GEMS
debase (0.2.2)
debase-ruby_core_source (0.10.3)
LOCAL GEMS *
ruby-debug-ide (0.6.1)

Launch.json

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

    {
        "name": "Rails server",
        "type": "Ruby",
        "request": "launch",
        "cwd": "${workspaceRoot}",
        "program": "${workspaceRoot}/bin/rails",
        "args": [
            "server"
        ]
    },
    {
        "name": "Listen for rdebug-ide",
        "type": "Ruby",
        "request": "attach",
        "cwd": "${workspaceRoot}",
        "remoteHost": "127.0.0.1",
        "remotePort": "1234",
        "remoteWorkspaceRoot": "${workspaceRoot}"
    },
]

}

Expected behavior

Rails server -> run a rails server and stop on breakpoints !
Listen for rdebug-ide -> attach to a rails console debug session

Actual behavior

Rails server does not launch. Only debug bar is displayed. Debug console is not automatically displayed
Only an 'Assertion failed' in OUTPUT console (Extensions).

Hope it'll help.

@foxpowa did you found any solution? can you share it? Thank you.

Hi @pablushka,
I’m not developping ruby apps anymore. I can’t remember workarounds I used.
Sorry!
I was using Rubymine for debugging when vs code extensions were not functional.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

archfish picture archfish  Â·  5Comments

epk picture epk  Â·  5Comments

wingrunr21 picture wingrunr21  Â·  4Comments

abraham picture abraham  Â·  4Comments

chrisnicola picture chrisnicola  Â·  5Comments