问题
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