# \`rake\` fails: Exec format error

**URL:** <https://rubytalk.org/t/rake-fails-exec-format-error/39797>\
**Category:** ruby-talk\
**Created:** [9 August 2007 23:37 UTC](https://rubytalk.org/t/rake-fails-exec-format-error/39797 "2007-08-09T23:37:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Larry\_Fast](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Larry\_Fast](https://rubytalk.org/u/Larry_Fast)\
**Post date:** [9 August 2007 23:37 UTC](https://rubytalk.org/t/rake-fails-exec-format-error/39797/1 "2007-08-09T23:37:15Z")

</div>

I'm trying to start rake running for a sub-component of our system.  
However Ruby doesn't like `rake` and produces the following error...

> ruby -e "`rake`" (it gives the same error inside my .rb files)

-e:1:in ``': Exec format error - rake (Errno::ENOEXEC)

I worked around it by creating a .rb file that contains:  
Rake::Task['taskname'].invoke

Is there a better way or a standard practice for invoking an external  
Rake process from inside Ruby?

Thanks,  
Larry

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Larry\_Fast](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Larry\_Fast](https://rubytalk.org/u/Larry_Fast)\
**Post date:** [10 August 2007 01:40 UTC](https://rubytalk.org/t/rake-fails-exec-format-error/39797/2 "2007-08-10T01:40:25Z")

</div>

A more complete version of what I'm doing is...

&nbsp;&nbsp;&nbsp;&nbsp;crntDir = Dir.pwd  
&nbsp;&nbsp;&nbsp;&nbsp;Dir.chdir("other\_directory\_path")  
&nbsp;&nbsp;&nbsp;&nbsp;%x{ruby -e "require 'Rakefile'; Rake::Task['some\_task'].invoke "}  
&nbsp;&nbsp;&nbsp;&nbsp;Dir.chdir(crntDir)

Is there a more elegant ruby-ism that accomplishes this?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada1](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Nobuyoshi\_Nakada1](https://rubytalk.org/u/Nobuyoshi_Nakada1)\
**Post date:** [10 August 2007 07:28 UTC](https://rubytalk.org/t/rake-fails-exec-format-error/39797/3 "2007-08-10T07:28:01Z")

</div>

Hi,

At Fri, 10 Aug 2007 08:37:15 +0900,  
Larry Fast wrote in [ruby-talk:264040]:

> I'm trying to start rake running for a sub-component of our system.  
> However Ruby doesn't like `rake` and produces the following error...
> 
> \> ruby -e "`rake`" (it gives the same error inside my .rb files)
> 
> -e:1:in ``': Exec format error - rake (Errno::ENOEXEC)

It depends on what's your platform and how you've installed  
rake.

> **···**
>
> --  
> Nobu Nakada

---

<div class="post-metadata">

**Author:** ![Stefano\_Crocco](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Stefano\_Crocco](https://rubytalk.org/u/Stefano_Crocco)\
**Post date:** [10 August 2007 06:51 UTC](https://rubytalk.org/t/rake-fails-exec-format-error/39797/4 "2007-08-10T06:51:28Z")

</div>

Alle venerdì 10 agosto 2007, Larry Fast ha scritto:

> A more complete version of what I'm doing is...
> 
> &nbsp;&nbsp;&nbsp;&nbsp;crntDir = Dir.pwd  
> &nbsp;&nbsp;&nbsp;&nbsp;Dir.chdir("other\_directory\_path")  
> &nbsp;&nbsp;&nbsp;&nbsp;%x{ruby -e "require 'Rakefile'; Rake::Task['some\_task'].invoke "}  
> &nbsp;&nbsp;&nbsp;&nbsp;Dir.chdir(crntDir)
> 
> Is there a more elegant ruby-ism that accomplishes this?

If you want to execute a rakefile, I think you can do:

%x{rake ...}

Stefano

---

<div class="post-metadata">

**Author:** ![Larry\_Fast](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Larry\_Fast](https://rubytalk.org/u/Larry_Fast)\
**Post date:** [10 August 2007 15:24 UTC](https://rubytalk.org/t/rake-fails-exec-format-error/39797/5 "2007-08-10T15:24:36Z")

</div>

> If you want to execute a rakefile, I think you can do:  
> %x{rake ...}

ruby -e '%x{rake}' produces the same error message

Nobuyoshi Nakada wrote:

> It depends on what's your platform and how you've installed  
> rake.

We're running Windows XP. ruby -v says:  
ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-mswin32]  
I don't know much more than that. I'm guessing we used the one-click  
installation.

Larry

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Larry\_Fast](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Larry\_Fast](https://rubytalk.org/u/Larry_Fast)\
**Post date:** [10 August 2007 15:28 UTC](https://rubytalk.org/t/rake-fails-exec-format-error/39797/6 "2007-08-10T15:28:16Z")

</div>

Larry Fast wrote:

> I'm guessing we used the one-click installation.

There are 3 rake files in my ruby installation directory:  
rake - near the top it reads # This file was generated by RubyGems.  
rake.bat - very similar to rake  
rake.cmd - one line: @ruby "C:/ruby/bin/rake" %\*

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada1](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Nobuyoshi\_Nakada1](https://rubytalk.org/u/Nobuyoshi_Nakada1)\
**Post date:** [10 August 2007 18:33 UTC](https://rubytalk.org/t/rake-fails-exec-format-error/39797/7 "2007-08-10T18:33:03Z")

</div>

Hi,

At Sat, 11 Aug 2007 00:28:16 +0900,  
Larry Fast wrote in [ruby-talk:264105]:

> There are 3 rake files in my ruby installation directory:  
> rake - near the top it reads # This file was generated by RubyGems.  
> rake.bat - very similar to rake  
> rake.cmd - one line: @ruby "C:/ruby/bin/rake" %\*

`rake.cmd` would work.

> **···**
>
> --  
> Nobu Nakada

---

<div class="post-metadata">

**Author:** ![Larry\_Fast](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Larry\_Fast](https://rubytalk.org/u/Larry_Fast)\
**Post date:** [10 August 2007 19:47 UTC](https://rubytalk.org/t/rake-fails-exec-format-error/39797/8 "2007-08-10T19:47:06Z")

</div>

Nobuyoshi Nakada wrote:

> `rake.cmd` would work.

Just tried it and yes, `rake.cmd` works.  
Thank you,  
Larry

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
