Debugging Ruby with Byebug

A guide on Byebug exists here

Couple of useful links:


Disappearing type!

At the moment it seems like the bash terminal can stop echoing your typing mid debug session. A simple workaround is to paste and enter this string, and the echoing will return:

`stty sane`

This is a known issue

You can make this even easier by binding this to a key combo, e.g. here in VS Code:

[{"key": "ctrl+u",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "`stty sane`" }}]

(NB I don’t think this is yet possible in the new Windows Terminal app, though, but feel free to amend this statement!)

Reduce the splurge to terminal

Defeat SQL logging

Consider getting rid of the SQL logging using:



Reduce the number of Unicorns

Reduce the number of unicorns in unicorn.conf.rb:

worker_processes (ENV["UNICORN_WORKERS"] || 1).to_i (from usually 3 to 1)

Prevent Discourse retrying to send failed emails

Finally, stop the system repeatedly failing to send mail:


Stop Controllers Timing out

Debugging controllers is a breeze with UNICORN_TIMEOUT environment variable.

I’ve added a couple more tips in ‘reduce splurge’ section:

1 Like

I see why you reduced the workers. Trying out byebug

Another thing to consider:

  • offload functionality from the Controller into library methods so you can test it in quiet isolation. The loss of visible text becomes really annoying with byebug, so for this reason alone it’s worthwhile.

Another thing I’m going to try is stop other threads whilst in a Controller, so see if that helps:

Something similar but needs no code tweaking


You set this variable to change the rails log level while starting the server.

Setting DISCOURSE_DEV_LOG_LEVEL=info gets rid of sql logging.

Debugging controllers is a breeze with UNICORN_TIMEOUT environment variable.

Great find! Probably still good practice to keep them simple?

For sure. Its for times when we want to debug monkey patches etc. that run in the context of a request.