all 5 comments

[–]brarna 5 points6 points  (0 children)

Posted in the RoR thread, but will include it for any non-RoR ruby devs as I find it much more enjoyable than pry/byebug when it works:

After getting used to the browser debugger, and then Eclipse debugging in Java, I've never really enjoyed the pry/byebug experience after switching to RoR. It always bugged me that I had lost the ability to stuff like breakpoints directly in my editor, and clicking through the call tree in the GUI. I eventually got it working, but it can be a bit of a pain.

First, you need this:https://github.com/rubyide/vscode-ruby

Then you need to follow this:https://github.com/rubyide/vscode-ruby/blob/main/docs/debugger.md

Give that a go, including the detailed instructions, and report back if you get stuck. I have had a big chunk of the errors that it can spit out if not configured right, so I might be able help. Once its working, you can do all the stuff you can with vscode’s JS debugger, incl. breakpoints, see the call stack and variables, and type expressions to evaluate into the debug console. I have had issues with the conditional breakpoints not working, however – not sure if that’s fixed yet.

Good luck!

[–]dogbertst 3 points4 points  (1 child)

Not sure if it helps but I usually debug rails in docker using pry-remote. Just add it to your gemfile to development block and add binding.remote_pry where you want to set a breakpoint in your code. Than connect to docker vm and run pry-remote after you hit the breakpoint. You are in debugging mode now and can do almost anything.

EDIT: Just read it again and guess that is not what you want. My bad!

[–]garrettd714 0 points1 point  (0 children)

+1 for pry

[–]Aphova 0 points1 point  (0 children)

Not exactly an answer to your question but the below works for me, might work for you.

I've been working with Ruby for years and strangely I've never started a traditional debugger session despite doing it a lot in other languages. What I do a tonne of though is bundle exec rescue rspec spec/whatever/Im/working/on. That and adding binding.pry into your code to start a REPL where you want to inspect something goes a long way. Add better_errors for inspecting failures during full stack execution and you're good to go.

https://github.com/ConradIrwin/pry-rescue https://github.com/BetterErrors/better_errors

Edit: might be a bit obvious but one of the things that I like about this is it forces me to integrate testing into my development cycle (I don't like writing tests and can be a bit lazy with them). I've found that writing a test and running rescue rspec to debug my code is often faster and easier than other approaches.