Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing to screen in a rake task

I have a long running rake task. Every now and then I print an update to the screen to let me know how far along the task has come.

puts "Almost there..."

My problem is all the puts statements seem to buffer somewhere and won't print to the screen until after the task is complete. At which point, they will be printed all at once.

Is there some way to force them to print as the task is running?

like image 998
Janak Avatar asked Feb 07 '10 01:02

Janak


People also ask

What are rake tasks used for?

Rake is a software task management and build automation tool created by Jim Weirich. It allows the user to specify tasks and describe dependencies as well as to group tasks in a namespace. It is similar in to SCons and Make.

How do I run a specific rake task?

Go to Websites & Domains and click Ruby. After gems installation you can try to run a Rake task by clicking Run rake task. In the opened dialog, you can provide some parameters and click OK - this will be equivalent to running the rake utility with the specified parameters in the command line.

How do you abort a rake task?

If you meant exiting from a rake task without causing the "rake aborted!" message to be printed, then you can use either "abort" or "exit".


1 Answers

STDOUT.sync = true
like image 95
kain Avatar answered Oct 03 '22 23:10

kain