# \[patch\] rake 0.7.3 to 0.8.x broke engines rake redefine\_task

**URL:** <https://www.ruby-forum.com/t/patch-rake-0-7-3-to-0-8-x-broke-engines-rake-redefine-task/124560>\
**Category:** Engines Development\
**Created:** [December 30, 2007, 8:07am UTC](https://www.ruby-forum.com/t/patch-rake-0-7-3-to-0-8-x-broke-engines-rake-redefine-task/124560 "2007-12-30T08:07:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdunneuk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jdunneuk](https://www.ruby-forum.com/u/jdunneuk)\
**Post date:** [December 30, 2007, 8:07am UTC](https://www.ruby-forum.com/t/patch-rake-0-7-3-to-0-8-x-broke-engines-rake-redefine-task/124560/1 "2007-12-30T08:07:51Z")

</div>

Hi,

The collaboa site for engines is having serious problems, so I’m posting  
here.

As mentioned previously, rake 0.8.x broke the code for redefining rake  
tasks.

The problem is that in rake 0.8.x, the first argument to resolve\_args  
should now be an array. Also, last\_comment was changed to  
last\_description.

So, this will only work with rake 0.8.x.

Any chance to get this patch into engines /branches/rb\_1.2? Not sure  
what should be done about BC on this. Any ideas?

Thanks,  
John

— engines.rake 2007-12-29 22:54:17.000000000 -0800  
+++ engines.rake.new 2007-12-29 22:54:10.000000000 -0800  
@@ -6,14 +6,14 @@  
module Rake  
module TaskManager  
def redefine\_task(task\_class, args, &block)

- 

```
   task_name, deps = resolve_args(args)

```

- 

```
   task_name, deps = resolve_args([args])
   task_name = task_class.scope_name(@scope, task_name)
   deps = [deps] unless deps.respond_to?(:to_ary)
   deps = deps.collect {|d| d.to_s }
   task = @tasks[task_name.to_s] = task_class.new(task_name, self)
   task.application = self

```

- 

```
   task.add_comment(@last_comment)

```

- 

```
   @last_comment = nil

```

- 

```
   task.add_description(@last_description)

```

- 

```
   @last_description = nil
   task.enhance(deps, &block)
   task
 end
```

---

<div class="post-metadata">

**Author:** ![jdunneuk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jdunneuk](https://www.ruby-forum.com/u/jdunneuk)\
**Post date:** [December 31, 2007, 6:22am UTC](https://www.ruby-forum.com/t/patch-rake-0-7-3-to-0-8-x-broke-engines-rake-redefine-task/124560/2 "2007-12-31T06:22:38Z")

</div>

Replying to myself. New patch. Here is a simple backwards-compatible  
patch that allows this to work for rake 0.7.3 and rake 0.8.x

Feel free to DRY this up or otherwise make it prettier.

I tested this with on my rails app with both rake 0.7.3 and 0.8.1.

Thanks,  
John

— engines.rake.old 2007-12-29 22:54:17.000000000 -0800  
+++ engines.rake 2007-12-30 20:16:10.000000000 -0800  
@@ -6,14 +6,19 @@  
module Rake  
module TaskManager  
def redefine\_task(task\_class, args, &block)

- 

```
   task_name, deps = resolve_args(args)

```

- 

```
   task_name, deps = (RAKEVERSION >= '0.8.0') ? 

```

resolve\_args([args]) : resolve\_args(args)  
task\_name = task\_class.scope\_name(@scope, task\_name)  
deps = [deps] unless deps.respond\_to?(:to\_ary)  
deps = deps.collect {|d| d.to\_s }  
task = @tasks[task\_name.to\_s] = task\_class.new(task\_name, self)  
task.application = self

- 

```
   task.add_comment(@last_comment)

```

- 

```
   @last_comment = nil

```

- 

```
   if RAKEVERSION >= '0.8.0'

```

- 

```
     task.add_description(@last_description)

```

- 

```
     @last_description = nil

```

- 

```
   else

```

- 

```
     task.add_comment(@last_comment)

```

- 

```
     @last_comment = nil

```

- 

```
   end
   task.enhance(deps, &block)
   task
 end
```

---

<div class="post-metadata">

**Author:** ![jdunneuk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jdunneuk](https://www.ruby-forum.com/u/jdunneuk)\
**Post date:** [January 3, 2008, 1:09pm UTC](https://www.ruby-forum.com/t/patch-rake-0-7-3-to-0-8-x-broke-engines-rake-redefine-task/124560/3 "2008-01-03T13:09:12Z")

</div>

Hi John,

Could you post this patch to the issue tracker?  
[http://dev.rails-engines.org](http://dev.rails-engines.org) - login info is on the  
[http://rails-engines.org](http://rails-engines.org) website.

Thanks!

James

---

<div class="post-metadata">

**Author:** ![jdunneuk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jdunneuk](https://www.ruby-forum.com/u/jdunneuk)\
**Post date:** [January 3, 2008, 6:28pm UTC](https://www.ruby-forum.com/t/patch-rake-0-7-3-to-0-8-x-broke-engines-rake-redefine-task/124560/4 "2008-01-03T18:28:53Z")

</div>

Hi James,

Happy to. Collaboa was giving errors last I tried.

On a related note, after posting to rake-devel, Jim W. (author of  
rake) offered to implement redefine\_task within rake proper, but is  
asking for input.

Would you be kind enough to jump-in with specifics on what engines needs  
for rake redefine\_task?

Here is the thread on rake list:  
[http://rubyforge.org/pipermail/rake-devel/2008-January/000357.html](http://rubyforge.org/pipermail/rake-devel/2008-January/000357.html)

Thanks!  
John

---

<div class="post-metadata">

**Author:** ![jdunneuk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jdunneuk](https://www.ruby-forum.com/u/jdunneuk)\
**Post date:** [January 3, 2008, 6:39pm UTC](https://www.ruby-forum.com/t/patch-rake-0-7-3-to-0-8-x-broke-engines-rake-redefine-task/124560/5 "2008-01-03T18:39:33Z")

</div>

On 1/3/08, John D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi James,
> 
> Happy to. Collaboa was giving errors last I tried.

Thanks 🙂

> Would you be kind enough to jump-in with specifics on what engines needs for rake redefine\_task?

Will do, and thanks for raising this on the rake list - it’s clearly  
something I should’ve done myself! I suppose the attitude of some of  
the guardians of the Rails codebase has sunk sufficiently into my  
subconscious that I no longer immediately consider feeding change  
requests back to original projects (!) 🙂
