I'm a Ruby newbie. I'm using TexMate Version 1.5.9 (1510) on Mac OS X Version 10.6.4. I'm trying to write a small Ruby snippet to get keyboard input as follows:
puts "What is your name? " name = gets.chomp puts "Hello #{name}"
I get the following TextMate error:
*NoMethodError:* private method ‘chomp’ called for nil:NilClass
*at top level*txmt://open?line=2&url=file:///Users/marcc/Documents/marccTechnical/Ruby/myRubyPrograms/sayhello.rb
in *sayhello.rb* at line 2
Program exited with code #1 after 0.02 seconds.
I've googled pretty much every piece of information on Ruby keyboard input, changed that little snippet many times accordingly, but I could never get it to work.
I realize that this question is not directly related to TextMate, but I'm hoping somebody can help me.
Thanks in advance,
Marc
On Nov 9, 2010, at 12:01 PM, Marc Chanliau wrote:
I'm a Ruby newbie. I'm using TexMate Version 1.5.9 (1510) on Mac OS X Version 10.6.4. I'm trying to write a small Ruby snippet to get keyboard input as follows:
puts "What is your name? " name = gets.chomp puts "Hello #{name}"
I get the following TextMate error:
NoMethodError: private method ‘chomp’ called for nil:NilClass
I'm no Ruby expert myself, but the problem you're seeing is that "gets" is nil, and therefore has no "chomp" to execute. "gets" is nil because you have no interactive input. The sad news is thus:
http://blog.macromates.com/2009/interactive-input/
You might try using TextMate's UI library and get a string from the user, if that's crucial to your snippet. A very simple example:
require ENV['TM_SUPPORT_PATH'] + '/lib/ui' userInput = TextMate::UI.request_string() puts userInput
Thanks for the helpful answer. Unfortunately, I'm on Snow Leopard, so the blog's workaround won't work for me. Adding the snippet you provided works, but that makes the program break in a regular terminal window, of course. For now, I'll run Ruby programs asking for user input directly from the terminal, but that's not cool. Is there a chance to see this feature supported again in a future TxMate update? Thanks, Marc
On Tue, Nov 9, 2010 at 1:00 PM, Dru Kepple dru@summitprojects.com wrote:
On Nov 9, 2010, at 12:01 PM, Marc Chanliau wrote:
I'm a Ruby newbie. I'm using TexMate Version 1.5.9 (1510) on Mac OS X Version 10.6.4. I'm trying to write a small Ruby snippet to get keyboard input as follows:
puts "What is your name? " name = gets.chomp puts "Hello #{name}"
I get the following TextMate error:
NoMethodError: private method ‘chomp’ called for nil:NilClass
I'm no Ruby expert myself, but the problem you're seeing is that "gets" is nil, and therefore has no "chomp" to execute. "gets" is nil because you have no interactive input. The sad news is thus:
http://blog.macromates.com/2009/interactive-input/
You might try using TextMate's UI library and get a string from the user, if that's crucial to your snippet. A very simple example:
require ENV['TM_SUPPORT_PATH'] + '/lib/ui' userInput = TextMate::UI.request_string() puts userInput
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On Tue, Nov 9, 2010 at 1:15 PM, Marc Chanliau marc.chanliau@gmail.comwrote:
Thanks for the helpful answer. Unfortunately, I'm on Snow Leopard, so the blog's workaround won't work for me. Adding the snippet you provided works, but that makes the program break in a regular terminal window, of course. For now, I'll run Ruby programs asking for user input directly from the terminal, but that's not cool. Is there a chance to see this feature supported again in a future TxMate update? Thanks, Marc
I'm also having this same problem, when it used to work just fine in the same version of TextMate. The only thing I can think of that changed is that I recently started using RVM to manage my rubies, but the ruby programs still run fine from the terminal, as you said... So unfortunately I don't know what the problem might be.
Marc Chanliau wrote:
Thanks for the helpful answer. Unfortunately, I'm on Snow Leopard, so the blog's workaround won't work for me.
I'm pretty sure that the problem with interactive input in SL was fixed some time back, at least in the "cutting edge" builds. Maybe try updating (via Preferences => Software Update => (watch for => cutting edge)). The cutting edge builds aren't all that cutting edge these days in any case :-(
Cheers, Paul
Thanks, Paul. Indeed it works with "cutting edge" build 1589. Thanks again. Marc
On Tue, Nov 9, 2010 at 1:45 PM, Paul McCann pmccann@gmail.com wrote:
Marc Chanliau wrote:
Thanks for the helpful answer. Unfortunately, I'm on Snow Leopard, so
the
blog's workaround won't work for me.
I'm pretty sure that the problem with interactive input in SL was fixed some time back, at least in the "cutting edge" builds. Maybe try updating (via Preferences => Software Update => (watch for => cutting edge)). The cutting edge builds aren't all that cutting edge these days in any case :-(
Cheers, Paul
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Agghhh! I was just prompted to download the latest update (1616), which I did, and sure enough, the keyboard input functionality is broken again. This is really annoying! Is there a way to get back to the earlier version (i.e., build 1589)? Again, this is really annoying... Marc
On Tue, Nov 9, 2010 at 10:12 PM, Marc Chanliau marc.chanliau@gmail.comwrote:
Thanks, Paul. Indeed it works with "cutting edge" build 1589. Thanks again. Marc
On Tue, Nov 9, 2010 at 1:45 PM, Paul McCann pmccann@gmail.com wrote:
Marc Chanliau wrote:
Thanks for the helpful answer. Unfortunately, I'm on Snow Leopard, so
the
blog's workaround won't work for me.
I'm pretty sure that the problem with interactive input in SL was fixed some time back, at least in the "cutting edge" builds. Maybe try updating (via Preferences => Software Update => (watch for => cutting edge)). The cutting edge builds aren't all that cutting edge these days in any case :-(
Cheers, Paul
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate