# Rake: race condition between task prerequisites

**URL:** <https://rubytalk.org/t/rake-race-condition-between-task-prerequisites/46026>\
**Category:** ruby-talk\
**Created:** [22 April 2008 12:58 UTC](https://rubytalk.org/t/rake-race-condition-between-task-prerequisites/46026 "2008-04-22T12:58:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tobie\_Langel](https://avatars.discourse-cdn.com/v4/letter/t/eb9ed0/32.png) [@Tobie\_Langel](https://rubytalk.org/u/Tobie_Langel)\
**Post date:** [22 April 2008 12:58 UTC](https://rubytalk.org/t/rake-race-condition-between-task-prerequisites/46026/1 "2008-04-22T12:58:46Z")

</div>

Hi,

I'm having a strange race condition between task prerequisites in the  
following rakefile:

> <https://github.com/tobie/prototype/blob/master/Rakefile>

At line #49, the :test rake tasks has the following prerequisites:  
:build\_tests, :dist and :test\_units.

:build\_tests is correctly executed, as the files are generated, but  
:test\_units doesn't wait for the files to be generated before running.

So the first time you run :test, no tests are called. (Subsequent calls  
do work, though).

I'm really not sure what I should be looking at to solve this problem.

Any pointers are welcomed.

Thanks,

Tobie

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Simon\_Krahnke](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Simon\_Krahnke](https://rubytalk.org/u/Simon_Krahnke)\
**Post date:** [22 April 2008 14:05 UTC](https://rubytalk.org/t/rake-race-condition-between-task-prerequisites/46026/2 "2008-04-22T14:05:07Z")

</div>

\* Tobie Langel \<tobie.langel@gmail.com\> (14:58) schrieb:

> I'm having a strange race condition between task prerequisites in the  
> following rakefile:
> 
> [prototype/Rakefile at master · tobie/prototype · GitHub](http://github.com/tobie/prototype/tree/master/Rakefile#L49)
> 
> At line #49, the :test rake tasks has the following prerequisites:  
> :build\_tests, :dist and :test\_units.
> 
> :build\_tests is correctly executed, as the files are generated, but  
> :test\_units doesn't wait for the files to be generated before running.

If :test\_units needs the result of :build\_tests, the latter should be a  
prerequisite of the first.

mfg, simon .... l

---

<div class="post-metadata">

**Author:** ![Tobie\_Langel](https://avatars.discourse-cdn.com/v4/letter/t/eb9ed0/32.png) [@Tobie\_Langel](https://rubytalk.org/u/Tobie_Langel)\
**Post date:** [22 April 2008 16:56 UTC](https://rubytalk.org/t/rake-race-condition-between-task-prerequisites/46026/3 "2008-04-22T16:56:13Z")

</div>

You mean as in: [http://pastie.caboo.se/184892](http://pastie.caboo.se/184892) ?

I had tried that earlier too (tried it again now to double-check),  
problem persists.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Tobie\_Langel](https://avatars.discourse-cdn.com/v4/letter/t/eb9ed0/32.png) [@Tobie\_Langel](https://rubytalk.org/u/Tobie_Langel)\
**Post date:** [22 April 2008 18:22 UTC](https://rubytalk.org/t/rake-race-condition-between-task-prerequisites/46026/4 "2008-04-22T18:22:15Z")

</div>

Hi again,

I ended up solving the issue. Turns out what I though was a block for  
the task was actually the block defining the task.

Sorry for the hassle.

Best,

Tobie

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Simon\_Krahnke](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Simon\_Krahnke](https://rubytalk.org/u/Simon_Krahnke)\
**Post date:** [23 April 2008 00:35 UTC](https://rubytalk.org/t/rake-race-condition-between-task-prerequisites/46026/5 "2008-04-23T00:35:03Z")

</div>

\* Tobie Langel \<tobie.langel@gmail.com\> (20:22) schrieb:

> You mean as in: [http://pastie.caboo.se/184892](http://pastie.caboo.se/184892) ?

Yes, why put it there instead just posting it here?

> I ended up solving the issue. Turns out what I though was a block for  
> the task was actually the block defining the task.

But the race condition is another thing, independent of the task doing  
the wrong thing.

mfg, simon .... l
