# Ocra: "Failed to create directory"

**URL:** <https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868>\
**Category:** Ruby\
**Created:** [May 26, 2009, 9:34pm UTC](https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868 "2009-05-26T21:34:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbaustert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@tbaustert](https://www.ruby-forum.com/u/tbaustert)\
**Post date:** [May 26, 2009, 9:34pm UTC](https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868/1 "2009-05-26T21:34:50Z")

</div>

Hello.

I was trying to use Ocra with Ruby 1.9.1 on Windows. It creates the  
executable but then when I try to run it, all I get is “Failed to create  
directory” on the console, and the program finishes. It’s hard to find  
any info about this error, so I’m asking if any of you happened to  
encounter and solve this problem, and could share their solution?

Thanks  
TPR.

---

<div class="post-metadata">

**Author:** ![tbaustert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@tbaustert](https://www.ruby-forum.com/u/tbaustert)\
**Post date:** [May 26, 2009, 9:56pm UTC](https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868/2 "2009-05-26T21:56:48Z")

</div>

I ran across this blog post that details some of common errors with  
Ocra,  
which mentions the error that you stated:

> **[The OCRA Compiler: Tips, Tricks, and Gotchas](http://rubyonwindows.blogspot.com/2009/05/ocra-compiler-tips-tricks-and-gotchas.html)**
>
> I've previously mentioned Lars Christensen's One-Click Ruby Application Builder , a "compiler" for Ruby scripts that shows a lot of potenti...

Hope that is of some help.

Alex

---

<div class="post-metadata">

**Author:** ![tbaustert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@tbaustert](https://www.ruby-forum.com/u/tbaustert)\
**Post date:** [May 26, 2009, 10:10pm UTC](https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868/3 "2009-05-26T22:10:03Z")

</div>

Alex wrote:

> [Ruby on Windows: The OCRA Compiler: Tips, Tricks, and Gotchas](http://rubyonwindows.blogspot.com/2009/05/ocra-compiler-tips-tricks-and-gotchas.html)

Thanks, but unfortunately this does not help. Also I tried both the gem  
version and the standalone version of Ocra, with the same error.

---

<div class="post-metadata">

**Author:** ![tbaustert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@tbaustert](https://www.ruby-forum.com/u/tbaustert)\
**Post date:** [May 27, 2009, 10:43am UTC](https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868/4 "2009-05-27T10:43:42Z")

</div>

Luis L. wrote:

> Can you provide more information about the version of Ruby, RubyGems  
> and application/script you’re trying to package?

ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32]

ocra (1.0.3)

Windows XP SP3

- RUBYGEMS VERSION: 1.3.3
- RUBY VERSION: 1.9.1 (2009-01-30 patchlevel 0) [i386-mswin32]
- RUBYGEMS PLATFORMS:
  - ruby
  - x86-mswin32-60

- GEM CONFIGURATION:
  - :update\_sources =\> true
  - :verbose =\> true
  - :benchmark =\> false
  - :backtrace =\> false
  - :bulk\_threshold =\> 1000

> If you can reproduce a simple “hello world” with the same problem,  
> will be great.

A simple “hello world” program works like it should. If I require and  
use any of the files from the standard library (like ‘matrix’,  
‘rexml/document’) it still works. Now if I require a gem file: for  
‘syntax’ (1.0.0) it works, and for ‘log4r’ (1.0.5) it fails with:

C:/DOCUME~1/TPReal/USTAWI~1/Temp/seb3B.tmp/src/\_hello.rb:2:in `require': no such file to load -- log4r (LoadError) from C:/DOCUME~1/TPReal/USTAWI~1/Temp/seb3B.tmp/src/_hello.rb:2:in`’

I do require ‘rubygems’ before ‘log4r’ in my script.

And to get the “Failed to create directory” error, I need to require my  
custom library file, which is located in D:\Ruby\_Files, and is  
accessible because “D:/Ruby/\_Files” is stored in RUBYLIB environment  
variable. Passing it as -I to ruby gives the same result.

Each time I run ocra I get WARNING: Couldn’t find enumerator.so. This is  
because $"[0] is “enumerator.so” (no full path). I don’t know why but I  
feel it is not a problem here.

Another question: is it possible with Ocra to include some static  
content in the package? I cannot find any info about that.

---

<div class="post-metadata">

**Author:** ![tbaustert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@tbaustert](https://www.ruby-forum.com/u/tbaustert)\
**Post date:** [May 27, 2009, 2:24am UTC](https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868/5 "2009-05-27T02:24:26Z")

</div>

On May 26, 5:10 pm, “Thomas B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Alex wrote:
> 
> > [http://rubyonwindows.blogspot.com/2009/05/ocra-compiler-tips-tricks-a](http://rubyonwindows.blogspot.com/2009/05/ocra-compiler-tips-tricks-a)…
> 
> Thanks, but unfortunately this does not help. Also I tried both the gem  
> version and the standalone version of Ocra, with the same error.

Can you provide more information about the version of Ruby, RubyGems  
and application/script you’re trying to package?

is more easy to find the issues if you provide more information about  
your environment. “Doesn’t work” don’t say too much.

ruby -v

gem env

Windows OS version?

If you can reproduce a simple “hello world” with the same problem,  
will be great.

---

<div class="post-metadata">

**Author:** ![tbaustert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@tbaustert](https://www.ruby-forum.com/u/tbaustert)\
**Post date:** [May 27, 2009, 1:40pm UTC](https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868/6 "2009-05-27T13:40:58Z")

</div>

On May 27, 5:43 am, “Thomas B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - RUBYGEMS VERSION: 1.3.3
> 
> file to load – log4r (LoadError)
> 
> Each time I run ocra I get WARNING: Couldn’t find enumerator.so. This is  
> because $"[0] is “enumerator.so” (no full path). I don’t know why but I  
> feel it is not a problem here.

That is really helpful information Thomas.

In case you’re aren’t aware, I’ve been working on a MinGW based  
version of Ruby.

Right now, 1.9.1-p129 for mingw32 include all the missing pieces  
required to actually run Ruby 1.9 on Windows.

Would you mind try using it instead of mswin32 version?

With the MinGW version, I never got the enumerator.so warning and no  
problem with RubyGems at all.

Please see the following posts in my blog about download links and  
instructions:

[http://blog.mmediasys.com/2009/05/05/rubyinstaller-state-of-one-click/](http://blog.mmediasys.com/2009/05/05/rubyinstaller-state-of-one-click/)  
[http://blog.mmediasys.com/2009/05/17/rubyinstaller-updated-packages-and-other-news/](http://blog.mmediasys.com/2009/05/17/rubyinstaller-updated-packages-and-other-news/)  
[http://blog.mmediasys.com/2009/05/19/pure-ruby-readline-released-012/](http://blog.mmediasys.com/2009/05/19/pure-ruby-readline-released-012/)

> Another question: is it possible with Ocra to include some static  
> content in the package? I cannot find any info about that.

I think is not, It doesn’t assume the current directory or the  
directory where the original executable is located, contrary to  
RubyScript2Exe which plays with LOAD\_PATH.

Maybe the following tips help you out:

> **[The OCRA Compiler: Tips, Tricks, and Gotchas](http://rubyonwindows.blogspot.com/2009/05/ocra-compiler-tips-tricks-and-gotchas.html)**
>
> I've previously mentioned Lars Christensen's One-Click Ruby Application Builder , a "compiler" for Ruby scripts that shows a lot of potenti...

Please check the mingw32 version and issues with it, and I’ll really  
love to help you out.

---

<div class="post-metadata">

**Author:** ![tbaustert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@tbaustert](https://www.ruby-forum.com/u/tbaustert)\
**Post date:** [February 24, 2010, 10:31pm UTC](https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868/7 "2010-02-24T22:31:34Z")

</div>

I just ran into this exact problem. I fixed my particular problem. Here  
is what I did.

I found that I could compile some scripts (even complex ones) but not  
others. I finally realized what the problem was. It appears ocra can’t  
handle if your script changes the working directory in the script. I  
believe orca should save the directory it is run in and then reference  
that directory but it apparently assumes the directory you start your  
script in is the same directory when it finishes. In my case, I am  
changing the directory.

in my case, I can reproduce this issue with the following code.

#start of script  
puts Dir.pwd  
dir = “d:/” #Dir.pwd produces “c:” so I changed to another drive  
(another directory will produce same result)  
Dir.chdir(dir)  
puts Dir.pwd  
puts “script complete”  
#end of script

I am not by any means an expert Ruby developer so I’m sure much of my  
nomenclature isn’t correct but this is what I did to fix my problem.

thanks,  
Domenic

Thomas B. wrote:

> Hello.
> 
> I was trying to use Ocra with Ruby 1.9.1 on Windows. It creates the  
> executable but then when I try to run it, all I get is “Failed to create  
> directory” on the console, and the program finishes. It’s hard to find  
> any info about this error, so I’m asking if any of you happened to  
> encounter and solve this problem, and could share their solution?
> 
> Thanks  
> TPR.

---

<div class="post-metadata">

**Author:** ![tbaustert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@tbaustert](https://www.ruby-forum.com/u/tbaustert)\
**Post date:** [February 24, 2010, 11:09pm UTC](https://www.ruby-forum.com/t/ocra-failed-to-create-directory/168868/8 "2010-02-24T23:09:05Z")

</div>

Just to be clear, the following runs correctly after compiling:

puts Dir.pwd  
olddir = Dir.pwd  
dir = “d:\”  
Dir.chdir(dir)  
puts Dir.pwd  
Dir.chdir(olddir)  
puts Dir.pwd  
puts “script complete”

whereas this code does not run correctly after compiling.

puts Dir.pwd  
olddir = Dir.pwd  
dir = “d:\”  
Dir.chdir(dir)  
puts Dir.pwd  
puts “script complete”

Domenic P. wrote:

> I just ran into this exact problem. I fixed my particular problem. Here  
> is what I did.
> 
> I found that I could compile some scripts (even complex ones) but not  
> others. I finally realized what the problem was. It appears ocra can’t  
> handle if your script changes the working directory in the script. I  
> believe orca should save the directory it is run in and then reference  
> that directory but it apparently assumes the directory you start your  
> script in is the same directory when it finishes. In my case, I am  
> changing the directory.
> 
> in my case, I can reproduce this issue with the following code.
> 
> #start of script  
> puts Dir.pwd  
> dir = “d:/” #Dir.pwd produces “c:” so I changed to another drive  
> (another directory will produce same result)  
> Dir.chdir(dir)  
> puts Dir.pwd  
> puts “script complete”  
> #end of script
> 
> I am not by any means an expert Ruby developer so I’m sure much of my  
> nomenclature isn’t correct but this is what I did to fix my problem.
> 
> thanks,  
> Domenic
> 
> Thomas B. wrote:
> 
> > Hello.
> > 
> > I was trying to use Ocra with Ruby 1.9.1 on Windows. It creates the  
> > executable but then when I try to run it, all I get is “Failed to create  
> > directory” on the console, and the program finishes. It’s hard to find  
> > any info about this error, so I’m asking if any of you happened to  
> > encounter and solve this problem, and could share their solution?
> > 
> > Thanks  
> > TPR.
