# Nested Rails Files

**URL:** <https://www.ruby-forum.com/t/nested-rails-files/129960>\
**Category:** Ruby\
**Created:** [February 23, 2008, 2:15am UTC](https://www.ruby-forum.com/t/nested-rails-files/129960 "2008-02-23T02:15:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wannabe-coder](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8e7dd6/32.png) [@wannabe-coder](https://www.ruby-forum.com/u/wannabe-coder)\
**Post date:** [February 23, 2008, 2:15am UTC](https://www.ruby-forum.com/t/nested-rails-files/129960/1 "2008-02-23T02:15:20Z")

</div>

I’m having trouble making nested Rakefiles work. Say I have the  
following:

- Raketest  
Rakefile
  - Child  
Rakefile

This is a Raketest folder containing a rakefile, and a child folder  
containing a different rakefile. In the Raketest folder, I have the  
following Rakefile:

task :default do  
sh “cd Child;rake”  
end

The Child folder under this has the following Rakefile:

task :default do  
puts “Child Rake Default task”  
end

The following shows the result of running rake first in the child  
folder, then in the Raketest folder:

C:\Raketest\Child\>rake  
(in C:/Raketest/Child)  
Child Rake Default task

C:\Raketest\Child\>cd …

C:\Raketest\>rake  
cd Child;rake  
(in C:/Raketest)  
The system cannot find the path specified.  
rake aborted!  
Command failed with status (1): [cd Child;rake…]  
C:/Raketest/rakefile.rb:2  
(See full trace by running task with --trace)

When I run rake in the child folder, it works. When I run rake in the  
Raketest folder, I get the “The system cannot find the path specified.”  
message. So what am I missing?

Just for good measure, I uninstalled all versions of Rake (via gem) then  
installed the latest version, which didn’t change anything.

I’ve attached my zipped contrived sample. I’d appreciate any help.

---

<div class="post-metadata">

**Author:** ![wannabe-coder](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8e7dd6/32.png) [@wannabe-coder](https://www.ruby-forum.com/u/wannabe-coder)\
**Post date:** [February 23, 2008, 10:10am UTC](https://www.ruby-forum.com/t/nested-rails-files/129960/2 "2008-02-23T10:10:26Z")

</div>

Joe Wirtley wrote:

> When I run rake in the child folder, it works. When I run rake in the  
> Raketest folder, I get the “The system cannot find the path specified.”  
> message. So what am I missing?

On UNIX (MacOS):  
$ cat lib/tasks/Raketest/Rakefile  
task :default do  
sh “cd Child;rake”  
end  
$ cd lib/tasks/Raketest/  
$ rake  
(in /Users/bush/Src/Rails/sample/lib/tasks/Raketest)  
cd Child;rake  
(in /Users/bush/Src/Rails/sample/lib/tasks/Raketest/Child)  
Child Rake Default task  
$ rake --version  
rake, version 0.8.1

My guess is that it has something to do with the way OS commands are  
being executed under Windows. Can you run “cd Child; rake” like that  
from the Windows prompt and get the right thing?

---

<div class="post-metadata">

**Author:** ![wannabe-coder](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8e7dd6/32.png) [@wannabe-coder](https://www.ruby-forum.com/u/wannabe-coder)\
**Post date:** [February 23, 2008, 11:06am UTC](https://www.ruby-forum.com/t/nested-rails-files/129960/3 "2008-02-23T11:06:13Z")

</div>

Mark B. wrote:

> Joe Wirtley wrote:
> 
> > When I run rake in the child folder, it works. When I run rake in the  
> > Raketest folder, I get the “The system cannot find the path specified.”  
> > message. So what am I missing?  
> > […]
> 
> My guess is that it has something to do with the way OS commands are  
> being executed under Windows. Can you run “cd Child; rake” like that  
> from the Windows prompt and get the right thing?

For Windows cmd.exe, you can’t use ‘;’ to separate commands. You  
have to use ‘&’ to unconditionally them one after the other.

sh “cd Child & rake” # Windows only

Maybe ‘&&’ will work on Unix and Windows.

sh “cd Child && rake”

Daniel

---

<div class="post-metadata">

**Author:** ![wannabe-coder](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8e7dd6/32.png) [@wannabe-coder](https://www.ruby-forum.com/u/wannabe-coder)\
**Post date:** [February 23, 2008, 5:27pm UTC](https://www.ruby-forum.com/t/nested-rails-files/129960/4 "2008-02-23T17:27:45Z")

</div>

Daniel SchÃ¶mer wrote:

> Mark B. wrote:
> 
> > Joe Wirtley wrote:
> > 
> > > When I run rake in the child folder, it works. When I run rake in the  
> > > Raketest folder, I get the “The system cannot find the path specified.”  
> > > message. So what am I missing?  
> > > […]
> 
> For Windows cmd.exe, you can’t use ‘;’ to separate commands. You  
> have to use ‘&’ to unconditionally them one after the other.
> 
> sh “cd Child & rake” # Windows only
> 
> Maybe ‘&&’ will work on Unix and Windows.
> 
> sh “cd Child && rake”
> 
> Daniel

Thanks to both of you. I knew it had to be something simple. Both ‘&’  
and ‘&&’ appear to work on Windows.
