rdbg prompt never appears, I can't see what I type (terminal echo) when using bin/dev (Foreman)
Your environment
- ruby 3.1.2p20
- rdbg 1.5.0
- rails 7.0.3
- Mac M1 (Apple Silicon)
Describe the bug
I added binding.break to my rails controller, and it breaks as expected. But there is no rdbg prompt, and I can't see what I type in the terminal. And when I do type something, I have to hit enter several times to get a response. And the response is always an error, since it only accepts the first character of what I typed.
Ok, I figured out that this only happens when I'm using bin/dev to run my development server. rails server does not have this problem. So it has something to do with using Foreman to run multiple processes in parallel. Any ideas about how to fix this?
@marshmallowcreme 👋 recently, I came in contact with a Rust-based Foreman cousin: mprocs, which starts described processes and allows you to switch between them, a bit like tmux (or screen). It allows you to interact with the debugger normally (seeing what you wrote).
This may or may not be relevant to your quest.
@olleolleolle Thanks. I tried it out, but was unable to see any echo in the terminal window, and no rdbg prompt. Hitting enter would return nothing.
@marshmallowcreme Thanks for trying it out. Perhaps that ruled out something.
I'm not sure about the architecture of foreman, but there are issue reports. I want to wait for the person who knows details...
@marshmallowcreme Just to narrow down the cause, do you see a similar issue when using binding.irb?
👋 FWIW I have a similar issue, with a similar machine and Ruby/Rails versions. Neither binding.irb nor debugeer work. Running bin/rails s (i.e. outside of Foreman) allows me to debug.
Can I help provide more info for this somehow?
An alternative is to have debug listen on a port or socket, and then connect a separate debugger process to that port or socket.
You can update your Procfile.dev to do this for you.
bin/rdbg --port 3001 --open --nonstop --command -- bin/rails server
Then just run a debugger process in another window.
bin/rdbg -A 3001
Having debug and foreman work correctly together might be tough as they are possibly both competing for stdin.
I have the same problem, but the debugger just hangs with bin/rails s, no interactive shell starts and I can't Ctrl-C to stop the server.
An alternative is to have debug listen on a port or socket, and then connect a separate debugger process to that port or socket.
You can update your
Procfile.devto do this for you.bin/rdbg --port 3001 --open --nonstop --command -- bin/rails serverThen just run a debugger process in another window.
bin/rdbg -A 3001Having
debugandforemanwork correctly together might be tough as they are possibly both competing for stdin.
@adam12 what is inside bin/rdbg? Thanks
what is inside
bin/rdbg? Thanks
@elalemanyo It's the debug binstub from bundler. bundler binstubs debug
It is not possible to interact directly with a debug breakpoint (or pry's or byebug's I believe as well) within the foreman process because it is just streaming the output of however many processes you define in your procfile.
You can however, enable remote debugging for debug when you start the rails app, so that you can run your foreman process in one terminal tab/window, and run rdbg -a in a separate terminal tab/window that connects to it.
Here's a blog post with more information: https://dev.to/ayushn21/remote-debugging-in-rails-7-49nh
Edit: Sorry, I missed @adam12's post which is essentially the same solution