Debugging Ruby with VSCode

Hey guys, I thought I’d share some significant pain I’ve been having and a temporary workaround.

Now, my preferred way of working involves using a remote dev server in the cloud and a non-docker install.

For this I used to use Atom and the nuclide add-in, but unfortunately Facebook has stopped providing support for that so I decided to make a break completely and moved to VS Code.

Now Microsoft themselves support a very good Remote SSH plugin that allows remote development and it’s very well integrated, even picking up your local SSH config and using that for the UI.

However, I ran into trouble debugging.

I have been using byebug quite a lot, but recently with such a heavy workload I’ve found it to be insufficient to keep pace. Additionally I found it very confusing when you are dealing with multiple threads as the console based UI gets corrupted by logging from other threads.

So at first I decided to move to VSCode based debugging using the Ruby extension but unfortunately the debugger seems really hard to get to work reliably.

I thought it was my problem but after a day or two researching the problem I found this on GitHub: it appears the plugin’s debugger has real problems:

Looks like there is some hope on the horizon though and imminently as the maintainer is promising an upgrade to the debugger before Ruby Conf in November.

So for now I’ve switched back, reluctantly to byebug but have one BIG tip, which was highlighted when @gdpelican posted about this issue on meta:

Reducing the number of web workers seems to help with the console log conflict:

  1. Locate /config/unicorn.conf.rb


worker_processes (ENV["UNICORN_WORKERS"] || 3).to_i


worker_processes (ENV["UNICORN_WORKERS"] || 1).to_i

Restart your server. Hope this helps!

If you have any suggestions or comments on remote debug, I’m all ears!

10 posts were split to a new topic: Choice of Editor