Ruby 调试器在 STDIN.gets 用户输入时失败

Ruby debugger fails on STDIN.gets user input

相信您可以轻松重现问题。 只需要一个新的 Ruby我的 (7.1) — Mac 或 Windows 版本,Ruby 2.2,创建简单的脚本:

puts "Hi, i'm gonna break your debugger :)"
user_input = gets
puts "Here should be breakpoint"

将断点放在第 3 行和 运行 调试会话(Ruby我的使用 ruby-debug-ide gem)。

当您在 Ruby我的控制台 window 中输入内容以便脚本在 gets 中读取时 — 程序不会吃掉您的输入说:

Could not execute statement: current stack frame is unavailable. Pause the process to use console interpreter

这是怎么回事?如何调试此类 Ruby 脚本?

这似乎是 RubyMine 的一个怪癖。如果您通过单击调试窗格中的 'Show Console Prompt' 图标禁用控制台提示,这应该会按您预期的方式开始工作

如果您正在努力寻找 'Show Console Prompt'enter image description here

,请参阅随附的屏幕截图