Why isn't 'gets' working in my Ruby script when I run from TextMate?
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开发者_StackOverflow社区'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.
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.
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.
精彩评论