Why isn't 'gets' working in my Ruby script when I run from TextMate?

狂风中的少年 提交于 2019-12-01 07:56:53

问题


When running the following ruby script:

puts gets.inspect

On the terminal I am prompted for input and then the inspect output is shown, but if I run the same script from inside TextMate using the CMD+R shortcut then it just outputs nil as if there is no gets method.

Why is this? From what I've read TextMate is supposed to show an input dialog when input from STDIN is requested by the script, but that isn't happening in this case.


回答1:


See this blog entry; presumably you're on Snow Leopard?

From the comments, some users say that this file has worked for them on Snow Leopard. Per @dmarkow's answer, copy this file to:
/Applications/TextMate.app/Contents/SharedSupport/Support/lib/
You may want to keep a copy of the file around as updates to TextMate may replace it.




回答2:


Specifically, you need to copy the tm_interactive_input.dylib file linked to by Phrogz in the following path:

/Applications/TextMate.app/Contents/SharedSupport/Support/lib/tm_interactive_input.dylib

Keep in mind that it's possible any TextMate updates will overwrite or delete this file.



来源:https://stackoverflow.com/questions/4731896/why-isnt-gets-working-in-my-ruby-script-when-i-run-from-textmate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!