Ruby调试器在STDIN上失败。获取用户输入 [英] Ruby debugger fails on STDIN.gets user input

查看:182
本文介绍了Ruby调试器在STDIN上失败。获取用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I believe you can easily reproduce the issue. Just take a fresh RubyMine (7.1) — either Mac or Windows version, Ruby 2.2, create simple script:

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

将断点放在第三行并运行Debug会话(RubyMine使用 ruby​​-debug-ide gem)。

Put the breakpoint on the 3-rd line and run Debug session (RubyMine uses ruby-debug-ide gem).

当您在RubyMine控制台窗口中键入某些内容以供脚本读取获取时-程序不会吃掉您的输入内容:

When you type something in RubyMine console window for the script to read in gets — program doesn't eat your input saying:


无法执行语句:当前堆栈帧不可用。暂停
使用控制台解释器的过程

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

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

What's going on here and how can you debug such Ruby scripts?

推荐答案

这似乎是RubyMine的怪癖。如果您通过在调试窗格中单击显示控制台提示图标来禁用控制台提示,则该控制台提示应会按预期运行

This appears to be a RubyMine quirk. If you disable the console prompt by clicking on the 'Show Console Prompt' icon in the debug pane this should start working as you expect

如果您正在努力在此处找到显示控制台提示 在此处输入图片描述

See attached Screenshot if you are struggling to find the 'Show Console Prompt'enter image description here

这篇关于Ruby调试器在STDIN上失败。获取用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆