title: How do I call another task in Rake
body: <p>Although this might sound similar to the other questions you find here, there is a slight twist. I have two directories, say /home/rails/Rake and /home/rails/test_app. The rails directory is where I place all my rails projects. </p>
  
  <p>Inside Rake, I have a <em>Rakefile</em> and a <em>create.rake</em> file.</p>
  
  <p>This is what my <em>rakefile</em> look's like</p>
  
  <pre><code>namespace :setup do 
      desc "something"
      task :init do
          print "Name of the destination directory: "
          name = STDIN.gets.strip
          cp_r '.', "../#{name}/lib/tasks"
          cd  "../#{name}"
          sh "rake setup:create"
  
      end
  end
  </code></pre>
  
  <p>And <em>create.rake</em></p>
  
  <pre><code>namespace :setup do 
      desc "Install"
      task :create do
          sh 'git init'
          #some other code
      end
  end
  </code></pre>
  
  <p>What it does is obvious. I want to copy the contents of the Rake directory to /test_app/lib/tasks. Then change directory to test_app and run setup:create task defined in the install.rake file now placed in test_app/lib/tasks. This works, but is this the rake way of doing  it? Can anyone give me a slight hint of how it's done, the Rake way.</p>
  
  <p>Here is the error which I get when I used invoke method:</p>
  
  <pre><code>$ rake setup:init
  Name of the destination directory: 
  testapp
  cp -r . ../testapp/lib/tasks
  cd ../testapp
  rake aborted!
  Don't know how to build task 'setup:create'
  /home/TradeRaider/rails/Rake/Rakefile:8:in `block (2 levels) in &lt;top (required)&gt;'
  /home/TradeRaider/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
  /home/TradeRaider/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `&lt;main&gt;'
  Tasks: TOP =&gt; setup:init
  (See full trace by running task with --trace)
  </code></pre>