Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

ruby debug functionality is not working #129

Closed

Description

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.

Activity

  1. raldred commented on Apr 7, 2017

    @raldred

    Will you post your launch.json?

  2. davrem commented on Apr 18, 2017

    @davrem

    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
        }
    ]
    

    }

  3. sergd2005 commented on May 9, 2017

    @sergd2005

    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"
    ]
    }
    ]
    }

  4. seweil commented on Sep 1, 2017

    @seweil

    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.

  5. raldred commented on Sep 2, 2017

    @raldred
  6. seweil commented on Sep 5, 2017

    @seweil

    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")

  7. wingrunr21 commented on Apr 3, 2018

    @wingrunr21
    Collaborator

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

  8. jzajac2 commented on Oct 8, 2018

    @jzajac2

    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?

  9. wingrunr21 commented on Oct 8, 2018

    @wingrunr21
    Collaborator

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

    How do you have the debugging gems installed?

  10. jzajac2 commented on Oct 8, 2018

    @jzajac2

    @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}"
            },
    
  11. wingrunr21 commented on Oct 8, 2018

    @wingrunr21
    Collaborator

    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.

  12. jzajac2 commented on Oct 9, 2018

    @jzajac2

    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'
    
  13. tgmerritt commented on Feb 1, 2019

    @tgmerritt

    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.

  14. qortex commented on Feb 12, 2019

    @qortex

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

  15. bradleygolden commented on Mar 6, 2019

    @bradleygolden

    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.

  16. senhalil commented on Mar 6, 2019

    @senhalil

    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 #448 (comment) #448 (comment)

    Any help would be very much appreciated :)

  17. bradleygolden commented on Mar 7, 2019

    @bradleygolden

    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.

  18. tomraulet commented on Mar 13, 2019

    @tomraulet

    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.

  19. Pablushka commented on Jan 18, 2020

    @Pablushka

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

  20. tomraulet commented on Jan 18, 2020

    @tomraulet

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about project

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions