Ocra: "Failed to create directory"

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.

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

Hope that is of some help.

Alex

Alex wrote:

Ruby on Windows: The OCRA Compiler: Tips, Tricks, and Gotchas

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

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.

On May 26, 5:10 pm, “Thomas B.” [email protected] wrote:

Alex wrote:

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.

On May 27, 5:43 am, “Thomas B.” [email protected] 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/17/rubyinstaller-updated-packages-and-other-news/
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:

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

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.

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.