'Breakpoint not working on VScode for Rspec Rails

Not sure what's wrong with my setup. I've been stuck on this issue for a day now and still hasn't resolved this. I've setup my VScode so I can debug my specs (for Ruby on Rails) faster. I followed this guide on Github, originally stumbled upon this Stackoverflow thread here.

I've added ruby-debug-ide & debase under the development and test group in my gem file & execute $ bundle install. They seem to be working ok (I think) based on what I can see on my debug console.

Gemfile:

group :development, :test do
  gem 'ruby-debug-ide'
  gem 'debase'
end

Debug console:

This is how it looks like after pressing F5 or clicking the "Run" button under the Run & Debug tab on VSCode.

enter image description here

Looking at this part of the debug console I know that my spec file is being executed properly:

enter image description here

Launch.json file:

{
  "configurations": [
    {
      "name": "Debug RSpec - open spec file",
      "type": "Ruby",
      "request": "launch",
      "cwd": "${workspaceRoot}",
      "useBundler": true,
      "pathToBundler": "/Users/<my computer name>/.rbenv/shims/bundle",
      "pathToRDebugIDE": "/Users/<my computer name>/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ruby-debug-ide-0.7.3",
      "debuggerPort": "1235",
      "program": "${workspaceRoot}/bin/rspec",
      "args": [
        "${file}"
      ],
      "showDebuggerOutput": true
    },
  ]
}

I've added a breakpoint on my spec file (even tried adding multiple breakpoints) but it's debugger isn't hitting any of it. Made sure it's turned on (See screenshot below).

enter image description here

Other info about my setup that might help, tell me if you need more info:

  • Machine is MBP 2021 Intel
  • OS: Mac OS Monterey 12.0.1
  • Latest version of VSCode installed
  • Ruby version: ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin20
  • Rails version: Rails 5.2.3
  • Version manager: RBenv


Solution 1:[1]

For everyone's reference, this may not exactly answer my question above but I've already asked Mid-Senior developers from inside and outside of my workplace and they are all using byebug. I ended up using it too. But if you do have insights which can possibly help this thread, feel free to drop an input. Here's how you can use byebug.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lea Tinoso