# Rake question: How to call a task from a different namespace

**URL:** <https://rubytalk.org/t/rake-question-how-to-call-a-task-from-a-different-namespace/40065>\
**Category:** ruby-talk\
**Created:** [20 August 2007 19:48 UTC](https://rubytalk.org/t/rake-question-how-to-call-a-task-from-a-different-namespace/40065 "2007-08-20T19:48:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wayne\_E\_Seguin](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@Wayne\_E\_Seguin](https://rubytalk.org/u/Wayne_E_Seguin)\
**Post date:** [20 August 2007 19:48 UTC](https://rubytalk.org/t/rake-question-how-to-call-a-task-from-a-different-namespace/40065/1 "2007-08-20T19:48:25Z")

</div>

How does one call from inside a namespace, a task from another namespace?

namespace :foo do  
&nbsp;&nbsp;&nbsp;task :a do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "Hello from task a!"  
&nbsp;&nbsp;&nbsp;end  
end

namespace :bar do  
&nbsp;&nbsp;&nbsp;task :b do  
&nbsp;&nbsp;Rake::Task[:foo][:a] # How to call foo:a ???  
&nbsp;&nbsp;&nbsp;end  
end

Thanks!

&nbsp;&nbsp;&nbsp;~Wayne

s///g  
Wayne E. Seguin  
Sr. Systems Architect & Systems Administrator

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [20 August 2007 20:44 UTC](https://rubytalk.org/t/rake-question-how-to-call-a-task-from-a-different-namespace/40065/2 "2007-08-20T20:44:02Z")

</div>

Rake::Task['foo:a'].invoke

#invoke will only run a task once. If you want to force it to run (minus any prerequisites) call #execute.

> **···**
>
> On Aug 20, 2007, at 12:48, Wayne E. Seguin wrote:
> 
> > How does one call from inside a namespace, a task from another namespace?
> > 
> > namespace :foo do  
> > &nbsp;&nbsp;task :a do  
> > &nbsp;&nbsp;&nbsp;&nbsp;puts "Hello from task a!"  
> > &nbsp;&nbsp;end  
> > end
> > 
> > namespace :bar do  
> > &nbsp;&nbsp;task :b do  
> > &nbsp;&nbsp;Rake::Task[:foo][:a] # How to call foo:a ???  
> > &nbsp;&nbsp;end  
> > end
> 
> --  
> Poor workers blame their tools. Good workers build better tools. The  
> best workers get their tools to do the work for them. -- Syndicate Wars

---

<div class="post-metadata">

**Author:** ![Wayne\_E\_Seguin](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@Wayne\_E\_Seguin](https://rubytalk.org/u/Wayne_E_Seguin)\
**Post date:** [20 August 2007 20:53 UTC](https://rubytalk.org/t/rake-question-how-to-call-a-task-from-a-different-namespace/40065/3 "2007-08-20T20:53:34Z")

</div>

Thank you kindly!

&nbsp;&nbsp;&nbsp;~Wayne

s///g  
Wayne E. Seguin  
Sr. Systems Architect & Systems Administrator

> **···**
>
> On Aug 20, 2007, at 16:44 , Eric Hodel wrote:
> 
> > Rake::Task['foo:a'].invoke
> > 
> > #invoke will only run a task once. If you want to force it to run (minus any prerequisites) call #execute.
