Question

have a problem with compressing my script.

I have a main.rb and some classes in subfolders like Subfolder/Class.rb In my main.rb, I have the Classes declared like that:

require './Subfolder/Class.rb'

When I just run my main script, it works. Also my exe works, when it is in the same place as the main.rb.
But when I put the exe somewhere else I get this error:

C:/Users/MLEING~1/AppData/Local/Temp/ocr53C2.tmp/lib/ruby/site_ruby/1.9.1/rubyge
ms/custom_require.rb:36:in `require': cannot load such file -- ./Parsing/Calibra
tionState (LoadError) from C:/Users/MLEING~1/AppData/Local/Temp/ocr53C2.tmp/lib/ruby/site_ruby
/1.9.1/rubygems/custom_require.rb:36:in `require'
    from C:/Users/MLEING~1/AppData/Local/Temp/ocr53C2.tmp/src/main.rb:9:in `
<main>'

Can I somehow put the dependencies into my exe?
I also tried to include them like that:

ocra main.rb Subfolder/*.rb

But it doesn't help.

Was it helpful?

Solution

Have you tried making a ruby gem out of your project? http://guides.rubygems.org/make-your-own-gem/

Gems define their own dependencies.

OTHER TIPS

Your require is using a relative path from the current directory (which you can see because it starts with "./"

Instead, try:

require 'Subfolder/Class.rb'

And make sure $LOAD_PATH includes the location where all of your ruby code is unpacked (which you can look at by examining $0 (or figure out the full path from $0 and require the .rb with a full path)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top