[LRUG] Rake problem with gets

James Adam james.adam at gmail.com
Tue Jun 13 08:08:05 PDT 2006

As I recall, Rake changes the default $stdout/$stdin arrangement. If you call


It should work. I've just tried this

task :getting do
  print 'What is your name: '
  x = STDIN.gets
  puts "You'll never be as good as Steven Seagal, #{x}"

$ rake getting
(in /private/tmp)
What is your name: James
You'll never be as good as Steven Seagal, James


- james

On 6/13/06, Roland Swingler <roland.swingler at gmail.com> wrote:
> Hi all,
> Good to meet some of you the other night - I should definitely try to
> make more meetings. Also looking forward to the idea of a few hack
> nights that John mused about.
> Anyway, I have been doing some stuff with Rake at the moment, and have
> run into a bug / something I don't understand - if anyone can shed any
> light on the problem it would be much appreciated.
> Here is my example rakefile:
> task :getting do
>   x = gets
>   puts x
> end
> task :default => [:getting]
> In my actual file I'm using the gets to confirm that you really want
> to do some uploading after seeing what files have been changed. The
> problem - running just "rake" on the command line works fine, waiting
> for input - running "rake getting" gives me the following error:
> rake aborted!
> No such file or directory - getting
> /home/rolands/tests/rakefile.rb:2:in `gets'
> (See full trace by running task with --trace)
> Doing the trace I get:
> /home/rolands/tests/rakefile.rb:2:in `gets'
> /home/rolands/tests/rakefile.rb:2
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke'
> /usr/local/lib/ruby/1.8/thread.rb:135:in `synchronize'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
> /usr/local/bin/rake:18
> The only thing I'm suspicious of is the Mutex synchronize method call
> in line 135 - I know nothing about threading (in fact multithreading
> is a subject I'd be interested in hearing a talk about) but am
> guessing it might screw up input in some way?
> Any thoughts or if anyone has run into a similar problem - it would be
> great to hear. I'm running the stable snapshot version of ruby 1.8.4
> Cheers,
> Roland
> _______________________________________________
> chat mailing list
> chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org

* J *

More information about the Chat mailing list