Skip to content

Instantly share code, notes, and snippets.

@russelldavis
Last active June 3, 2019 16:42
Show Gist options
  • Save russelldavis/c6bc762ee0d576efc12f9f5a3af2ca2f to your computer and use it in GitHub Desktop.
Save russelldavis/c6bc762ee0d576efc12f9f5a3af2ca2f to your computer and use it in GitHub Desktop.
How to debug in byebug with stdin/stdout/stderr redirected
# Before calling `byebug`, run the following:
require 'io/console'
require 'byebug'
Readline.input = IO.console
Readline.output = IO.console
Byebug::Context.interface.instance_variable_set('@input', IO.console)
Byebug::Context.interface.instance_variable_set('@output', IO.console)
Byebug::Context.interface.instance_variable_set('@error', IO.console)
# This used to be built in to byebug (https://github.com/deivid-rodriguez/byebug/pull/211)
# but it got reverted (https://github.com/deivid-rodriguez/byebug/pull/235/commits/4e6ad09a7710d546cc771b66123c12a74126bd90).
# Works great for me.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment