# Weird (Errno::ENOEXEC) - Ruby bug?

**URL:** <https://rubytalk.org/t/weird-errno-enoexec-ruby-bug/23231>\
**Category:** ruby-talk\
**Created:** [12 December 2005 22:52 UTC](https://rubytalk.org/t/weird-errno-enoexec-ruby-bug/23231 "2005-12-12T22:52:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kero1](https://avatars.discourse-cdn.com/v4/letter/k/0ea827/32.png) [@Kero1](https://rubytalk.org/u/Kero1)\
**Post date:** [12 December 2005 22:52 UTC](https://rubytalk.org/t/weird-errno-enoexec-ruby-bug/23231/1 "2005-12-12T22:52:38Z")

</div>

> > pr.rb contains:  
> > print "Hello!"
> > 
> > if test.rb contains:  
> > `pr.rb \> bloop`
> > 
> > then running test.rb from the command line results in bloop getting  
> > created and containing the expected test

$ ruby test.rb  
Warning: unknown mime-type for "Hello!" -- using "application/\*"

> > if test.rb contains:  
> > `pr.rb`
> > 
> > then running test.rb results in a runtime error:
> > 
> > test.rb:1:in ``': Exec format error - pr.rb

$ ruby test.rb  
test.rb:1: command not found: ./pr.rb

> > Can anyone explain what is going on?

Whatever executes pr.rb (some shell, in my case "bash" in your case??) must  
know that pr.rb contains \*ruby\* code. One way to do that, \*nix style, is this:

$ cat pr.rb  
#!/usr/bin/env ruby  
print "Hello!"  
$ cat test.rb  
`./pr.rb \> bloop`  
$ ruby test.rb  
$ cat bloop  
Hello!

Another is:

$ cat pr.rb  
print "Hello!"  
$ cat test.rb  
`ruby ./pr.rb \> bloop`  
$ cat bloop  
Hello!

Hth,  
Kero.
