# Rake: race condition between task prerequisites

**URL:** <https://www.ruby-forum.com/t/rake-race-condition-between-task-prerequisites/135466>\
**Category:** Ruby\
**Created:** [April 22, 2008, 2:58pm UTC](https://www.ruby-forum.com/t/rake-race-condition-between-task-prerequisites/135466 "2008-04-22T14:58:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/74df32/32.png) [@tobie](https://www.ruby-forum.com/u/tobie)\
**Post date:** [April 22, 2008, 2:58pm UTC](https://www.ruby-forum.com/t/rake-race-condition-between-task-prerequisites/135466/1 "2008-04-22T14:58:44Z")

</div>

Hi,

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

> <https://github.com/tobie/prototype/blob/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.

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

---

<div class="post-metadata">

**Author:** ![tobie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/74df32/32.png) [@tobie](https://www.ruby-forum.com/u/tobie)\
**Post date:** [April 22, 2008, 4:06pm UTC](https://www.ruby-forum.com/t/rake-race-condition-between-task-prerequisites/135466/2 "2008-04-22T16:06:45Z")

</div>

- Tobie L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) (14:58) schrieb:

> I’m having a strange race condition between task prerequisites in the  
> following rakefile:
> 
> [http://github.com/tobie/prototype/tree/master/Rakefile#L49](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](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/74df32/32.png) [@tobie](https://www.ruby-forum.com/u/tobie)\
**Post date:** [April 22, 2008, 6:56pm UTC](https://www.ruby-forum.com/t/rake-race-condition-between-task-prerequisites/135466/3 "2008-04-22T18:56:12Z")

</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.

---

<div class="post-metadata">

**Author:** ![tobie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/74df32/32.png) [@tobie](https://www.ruby-forum.com/u/tobie)\
**Post date:** [April 22, 2008, 8:22pm UTC](https://www.ruby-forum.com/t/rake-race-condition-between-task-prerequisites/135466/4 "2008-04-22T20:22:12Z")

</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

---

<div class="post-metadata">

**Author:** ![tobie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/74df32/32.png) [@tobie](https://www.ruby-forum.com/u/tobie)\
**Post date:** [April 23, 2008, 2:35am UTC](https://www.ruby-forum.com/t/rake-race-condition-between-task-prerequisites/135466/5 "2008-04-23T02:35:34Z")

</div>

- Tobie L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) (20:22) schrieb:

> You mean as in: [Parked at Loopia](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
