larsch / ocra

One-Click Ruby Application Builder
http://ocra.rubyforge.org/
833 stars 84 forks source link

Ocra not properly including Gems #174

Open Speak2Erase opened 3 years ago

Speak2Erase commented 3 years ago

I've got a script for reading and dumping serialized ruby files into text files, and I need to share this script with people who don't have ruby installed and would rather not go through the process. This script needs the zlib gem to function properly, and Ocra appears to be ignoring any command arguments and does not include zlib.so no matter how much I try. I already had to force it to load zlib by including it in a Gemfile, and including it with --gem-file has no effect. I am beginning to think Ocra is incredibly broken. Here's the command I'm running, and ocra's output: ocra .\mklangsrc.rb --dll ruby_builtin_dlls\libssp-0.dll --dll ruby_builtin_dlls\zlib1.dll --no-enc --no-dep-run --console --verbose --gemfile .\Gemfile --gem-files C:\Ruby27-x64\lib\ruby\gems\2.7.0\gems\zlib-1.1.0\lib\zlib.so

Resolving dependencies...
From Gemfile, adding gem bundler-2.1.4
From Gemfile, adding gem zlib-1.1.0
=== Detected gem bundler-2.1.4 (loaded, files, files)
===     4 files, 2686 bytes
=== Detected gem zlib-1.1.0 (loaded, files, files)
===     16 files, 197790 bytes
=== Detected gem did_you_mean-1.4.0 (loaded, files, files)
===     0 files, 0 bytes
=== Detected gem ocra-1.3.11 (loaded, files, files)
===     10 files, 543600 bytes
=== Detected gem uri-0.10.0 (loaded, files, files)
===     0 files, 0 bytes
=== Not including encoding support files
=== Building mklangsrc.exe
=== Adding user-supplied source files
m src
a src/mklangsrc.rb
m lib
m lib/ruby
m lib/ruby/gems
m lib/ruby/gems/2.7.0
m lib/ruby/gems/2.7.0/gems
m lib/ruby/gems/2.7.0/gems/zlib-1.1.0
m lib/ruby/gems/2.7.0/gems/zlib-1.1.0/lib
a lib/ruby/gems/2.7.0/gems/zlib-1.1.0/lib/zlib.so
=== Adding ruby executable ruby.exe
m bin
a bin/ruby.exe
a bin/x64-msvcrt-ruby270.dll
=== Adding detected DLL C:/Ruby27-x64/bin/ruby_builtin_dlls/libgmp-10.dll
m bin/ruby_builtin_dlls
a bin/ruby_builtin_dlls/libgmp-10.dll
=== Adding detected DLL C:/Ruby27-x64/bin/ruby_builtin_dlls/libffi-7.dll
a bin/ruby_builtin_dlls/libffi-7.dll
=== Adding external manifest C:/Ruby27-x64/bin/ruby_builtin_dlls/ruby_builtin_dlls.manifest
a bin/ruby_builtin_dlls/ruby_builtin_dlls.manifest
=== Adding supplied DLL ruby_builtin_dlls\libssp-0.dll
a bin/ruby_builtin_dlls/libssp-0.dll
=== Adding supplied DLL ruby_builtin_dlls\zlib1.dll
a bin/ruby_builtin_dlls/zlib1.dll
m lib/ruby/gems/2.7.0/specifications
m lib/ruby/gems/2.7.0/specifications/default
a lib/ruby/gems/2.7.0/specifications/default/did_you_mean-1.4.0.gemspec
a lib/ruby/gems/2.7.0/specifications/default/uri-0.10.0.gemspec
a lib/ruby/gems/2.7.0/specifications/ocra-1.3.11.gemspec
a lib/ruby/gems/2.7.0/specifications/zlib-1.1.0.gemspec
=== Adding library files
m lib/ruby/2.7.0
m lib/ruby/2.7.0/x64-mingw32
m lib/ruby/2.7.0/x64-mingw32/enc
a lib/ruby/2.7.0/x64-mingw32/enc/encdb.so
m lib/ruby/2.7.0/x64-mingw32/enc/trans
a lib/ruby/2.7.0/x64-mingw32/enc/trans/transdb.so
a lib/ruby/2.7.0/x64-mingw32/enc/windows_1252.so
a lib/ruby/2.7.0/x64-mingw32/rbconfig.rb
m lib/ruby/2.7.0/rubygems
a lib/ruby/2.7.0/rubygems/compatibility.rb
a lib/ruby/2.7.0/rubygems/defaults.rb
a lib/ruby/2.7.0/rubygems/deprecate.rb
a lib/ruby/2.7.0/rubygems/errors.rb
a lib/ruby/2.7.0/rubygems/version.rb
a lib/ruby/2.7.0/rubygems/requirement.rb
a lib/ruby/2.7.0/rubygems/platform.rb
a lib/ruby/2.7.0/rubygems/basic_specification.rb
a lib/ruby/2.7.0/rubygems/stub_specification.rb
a lib/ruby/2.7.0/rubygems/util.rb
a lib/ruby/2.7.0/rubygems/text.rb
a lib/ruby/2.7.0/rubygems/user_interaction.rb
a lib/ruby/2.7.0/rubygems/specification_policy.rb
m lib/ruby/2.7.0/rubygems/util
a lib/ruby/2.7.0/rubygems/util/list.rb
a lib/ruby/2.7.0/rubygems/specification.rb
a lib/ruby/2.7.0/rubygems/exceptions.rb
m lib/ruby/site_ruby
m lib/ruby/site_ruby/2.7.0
m lib/ruby/site_ruby/2.7.0/ruby_installer
m lib/ruby/site_ruby/2.7.0/ruby_installer/runtime
a lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/singleton.rb
a lib/ruby/site_ruby/2.7.0/ruby_installer/runtime.rb
a lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb
a lib/ruby/2.7.0/x64-mingw32/fiddle.so
m lib/ruby/2.7.0/fiddle
a lib/ruby/2.7.0/fiddle/function.rb
a lib/ruby/2.7.0/fiddle/closure.rb
a lib/ruby/2.7.0/fiddle.rb
a lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/dll_directory.rb
a lib/ruby/2.7.0/x64-mingw32/enc/utf_16le.so
a lib/ruby/2.7.0/x64-mingw32/enc/trans/utf_16_32.so
m lib/ruby/2.7.0/rubygems/defaults
a lib/ruby/2.7.0/rubygems/defaults/operating_system.rb
a lib/ruby/2.7.0/rubygems/bundler_version_finder.rb
a lib/ruby/2.7.0/rubygems/dependency.rb
m lib/ruby/2.7.0/rubygems/core_ext
a lib/ruby/2.7.0/rubygems/core_ext/kernel_gem.rb
a lib/ruby/2.7.0/x64-mingw32/monitor.so
a lib/ruby/2.7.0/monitor.rb
a lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb
a lib/ruby/2.7.0/rubygems/core_ext/kernel_warn.rb
a lib/ruby/2.7.0/rubygems.rb
a lib/ruby/2.7.0/rubygems/path_support.rb
m lib/ruby/2.7.0/did_you_mean
a lib/ruby/2.7.0/did_you_mean/version.rb
m lib/ruby/2.7.0/did_you_mean/core_ext
a lib/ruby/2.7.0/did_you_mean/core_ext/name_error.rb
a lib/ruby/2.7.0/did_you_mean/levenshtein.rb
a lib/ruby/2.7.0/did_you_mean/jaro_winkler.rb
a lib/ruby/2.7.0/did_you_mean/spell_checker.rb
m lib/ruby/2.7.0/did_you_mean/spell_checkers
m lib/ruby/2.7.0/did_you_mean/spell_checkers/name_error_checkers
a lib/ruby/2.7.0/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
a lib/ruby/2.7.0/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
a lib/ruby/2.7.0/did_you_mean/spell_checkers/name_error_checkers.rb
a lib/ruby/2.7.0/did_you_mean/spell_checkers/method_name_checker.rb
a lib/ruby/2.7.0/did_you_mean/spell_checkers/key_error_checker.rb
a lib/ruby/2.7.0/did_you_mean/spell_checkers/null_checker.rb
m lib/ruby/2.7.0/did_you_mean/formatters
a lib/ruby/2.7.0/did_you_mean/formatters/plain_formatter.rb
a lib/ruby/2.7.0/did_you_mean/tree_spell_checker.rb
a lib/ruby/2.7.0/did_you_mean.rb
a lib/ruby/2.7.0/tsort.rb
m lib/ruby/2.7.0/rubygems/request_set
a lib/ruby/2.7.0/rubygems/request_set/gem_dependency_api.rb
m lib/ruby/2.7.0/rubygems/request_set/lockfile
a lib/ruby/2.7.0/rubygems/request_set/lockfile/parser.rb
a lib/ruby/2.7.0/rubygems/request_set/lockfile/tokenizer.rb
a lib/ruby/2.7.0/rubygems/request_set/lockfile.rb
a lib/ruby/2.7.0/rubygems/request_set.rb
m lib/ruby/2.7.0/rubygems/resolver
m lib/ruby/2.7.0/rubygems/resolver/molinillo
m lib/ruby/2.7.0/rubygems/resolver/molinillo/lib
m lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/errors.rb
a lib/ruby/2.7.0/set.rb
m lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/state.rb
m lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/modules
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb
m lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/delegates
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/resolver.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo/lib/molinillo.rb
a lib/ruby/2.7.0/rubygems/resolver/molinillo.rb
a lib/ruby/2.7.0/rubygems/resolver/activation_request.rb
a lib/ruby/2.7.0/rubygems/resolver/conflict.rb
a lib/ruby/2.7.0/rubygems/resolver/dependency_request.rb
a lib/ruby/2.7.0/rubygems/resolver/requirement_list.rb
a lib/ruby/2.7.0/rubygems/resolver/stats.rb
a lib/ruby/2.7.0/rubygems/resolver/set.rb
a lib/ruby/2.7.0/rubygems/resolver/api_set.rb
a lib/ruby/2.7.0/rubygems/resolver/composed_set.rb
a lib/ruby/2.7.0/rubygems/resolver/best_set.rb
a lib/ruby/2.7.0/rubygems/resolver/current_set.rb
a lib/ruby/2.7.0/rubygems/resolver/git_set.rb
a lib/ruby/2.7.0/rubygems/resolver/index_set.rb
a lib/ruby/2.7.0/rubygems/resolver/installer_set.rb
a lib/ruby/2.7.0/rubygems/resolver/lock_set.rb
a lib/ruby/2.7.0/rubygems/resolver/vendor_set.rb
a lib/ruby/2.7.0/rubygems/resolver/source_set.rb
a lib/ruby/2.7.0/rubygems/resolver/specification.rb
a lib/ruby/2.7.0/rubygems/resolver/spec_specification.rb
a lib/ruby/2.7.0/rubygems/resolver/api_specification.rb
a lib/ruby/2.7.0/rubygems/resolver/git_specification.rb
a lib/ruby/2.7.0/rubygems/resolver/index_specification.rb
a lib/ruby/2.7.0/rubygems/resolver/installed_specification.rb
a lib/ruby/2.7.0/rubygems/resolver/local_specification.rb
a lib/ruby/2.7.0/rubygems/resolver/lock_specification.rb
a lib/ruby/2.7.0/rubygems/resolver/vendor_specification.rb
a lib/ruby/2.7.0/rubygems/resolver.rb
m lib/ruby/2.7.0/uri
a lib/ruby/2.7.0/uri/version.rb
a lib/ruby/2.7.0/uri/rfc2396_parser.rb
a lib/ruby/2.7.0/uri/rfc3986_parser.rb
a lib/ruby/2.7.0/uri/common.rb
a lib/ruby/2.7.0/uri/generic.rb
a lib/ruby/2.7.0/uri/file.rb
a lib/ruby/2.7.0/uri/ftp.rb
a lib/ruby/2.7.0/uri/http.rb
a lib/ruby/2.7.0/uri/https.rb
a lib/ruby/2.7.0/uri/ldap.rb
a lib/ruby/2.7.0/uri/ldaps.rb
a lib/ruby/2.7.0/uri/mailto.rb
a lib/ruby/2.7.0/uri.rb
m lib/ruby/2.7.0/rubygems/source
a lib/ruby/2.7.0/rubygems/source/git.rb
a lib/ruby/2.7.0/rubygems/source/installed.rb
a lib/ruby/2.7.0/rubygems/source/specific_file.rb
a lib/ruby/2.7.0/rubygems/source/local.rb
a lib/ruby/2.7.0/rubygems/source/lock.rb
a lib/ruby/2.7.0/rubygems/source/vendor.rb
a lib/ruby/2.7.0/rubygems/source.rb
a lib/ruby/2.7.0/x64-mingw32/enc/trans/single_byte.so
m lib/ruby/gems/2.7.0/extensions
m lib/ruby/gems/2.7.0/extensions/x64-mingw32
m lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0
m lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/zlib-1.1.0
a lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/zlib-1.1.0/gem.build_complete
m lib/ruby/gems/2.7.0/gems/bundler-2.1.4
m lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec
a lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundle
a lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundler
m lib/ruby/gems/2.7.0/gems/ocra-1.3.11
m lib/ruby/gems/2.7.0/gems/ocra-1.3.11/bin
a lib/ruby/gems/2.7.0/gems/ocra-1.3.11/bin/ocra
m lib/ruby/gems/2.7.0/gems/ocra-1.3.11/share
m lib/ruby/gems/2.7.0/gems/ocra-1.3.11/share/ocra
a lib/ruby/gems/2.7.0/gems/ocra-1.3.11/share/ocra/edicon.exe
a lib/ruby/gems/2.7.0/gems/ocra-1.3.11/share/ocra/lzma.exe
a lib/ruby/gems/2.7.0/gems/ocra-1.3.11/share/ocra/stub.exe
a lib/ruby/gems/2.7.0/gems/ocra-1.3.11/share/ocra/stubw.exe
a lib/ruby/gems/2.7.0/gems/zlib-1.1.0/.gitignore
a lib/ruby/gems/2.7.0/gems/zlib-1.1.0/.travis.yml
m lib/ruby/gems/2.7.0/gems/zlib-1.1.0/bin
a lib/ruby/gems/2.7.0/gems/zlib-1.1.0/bin/console
a lib/ruby/gems/2.7.0/gems/zlib-1.1.0/bin/setup
a lib/ruby/gems/2.7.0/gems/zlib-1.1.0/Gemfile
a lib/ruby/gems/2.7.0/gems/zlib-1.1.0/lib/zlib.so
a lib/ruby/gems/2.7.0/gems/zlib-1.1.0/zlib.gemspec
e RUBYOPT -Eutf-8
e RUBYLIB
e GEM_PATH <tempdir>\gemhome
p <tempdir>/bin/ruby.exe ruby.exe "<tempdir>\src\mklangsrc.rb"
=== Compressing 5993591 bytes

LZMA 19.00 (x86) : Igor Pavlov : Public domain : 2019-02-21

Input size:  5993591 (5 MiB)
Output size: 1879187 (1 MiB)
=== Finished building mklangsrc.exe (1929895 bytes)

Here's the error:


Traceback (most recent call last):
        2: from C:/Users/Matthew/AppData/Local/Temp/ocrBE69.tmp/src/mklangsrc.rb:2:in `<main>'
        1: from C:/Users/Matthew/AppData/Local/Temp/ocrBE69.tmp/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
C:/Users/Matthew/AppData/Local/Temp/ocrBE69.tmp/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- zlib (LoadError)
        3: from C:/Users/Matthew/AppData/Local/Temp/ocrBE69.tmp/src/mklangsrc.rb:2:in `<main>'
        2: from C:/Users/Matthew/AppData/Local/Temp/ocrBE69.tmp/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
        1: from C:/Users/Matthew/AppData/Local/Temp/ocrBE69.tmp/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `rescue in require'
C:/Users/Matthew/AppData/Local/Temp/ocrBE69.tmp/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `require': 126: The specified module could not be found.   - C:/Users/Matthew/AppData/Local/Temp/ocrBE69.tmp/lib/ruby/gems/2.7.0/gems/zlib-1.1.0/lib/zlib.so (LoadError)
Speak2Erase commented 3 years ago

Apparently that command just randomly started working. I don't know what I did, but whatever it was, it fixed something.

Speak2Erase commented 3 years ago

Nevermind, this is still very busted as I cannot get any other gems to require in without tinkering with --gem-file. I can't seem to easily include because it looks like ocra isn't actually including the actual gem itself.

m lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0
m lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0/.github
m lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0/.github/workflows
a lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0/.github/workflows/test.yml
a lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0/.gitignore
m lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0/bin
a lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0/bin/console
a lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0/bin/setup
a lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0/Gemfile
a lib/ruby/gems/2.7.0/gems/prettyprint-0.1.0/prettyprint.gemspec

Nowhere in here is Ocra actually logging that it is copying the lib folder over, rather it is instead copying everything BUT the lib folder. Hardcoding in the path of the lib folder for Ocra to include appears to fix this, and since nobody else really seems to have brought a solution to this up, I'll go ahead and document a workaround for anyone else having this problem. @Filechaser 's issues #169 also appears to be the same issue as this, but they were just left hanging with no resolution.

Ok, so my workaround (roughly) involves forcing Ocra to include with --gem-file and --gemfile (Note that these are different) For starters, you should go ahead and make a very basic Bundler Gemfile with a list of all your gems in this format: gem '<gem require name>'

You should then go ahead and point Ocra to that file by adding the flag --gemfile <path to gemfile>, and it should (hopefully) get Ocra to include all of the gem's files besides what is in the Lib folder. You then go head and find the installation path for that specific gem, (<ruby install>/lib/ruby/gems/<ruby version>/gems/) and then force Ocra to include the lib folder of that gem with the --gem-file flag. It should look like this: --gem-file C:\Ruby27-x64\lib\ruby\gems\2.7.0\gems\some-random-gem-4.20\lib

Repeat the above for every gem you need and you should be good! (Do note you will most likely end up with a very long command, especially when including gems that require other gems) I've found that this works for most gems, however I'm starting to run into issues including net::http and oj, when I get around to figuring them out I'll update this comment accordingly.

Edit: Hm, I've run into something where I'm getting a loaderror even when the specific file it's looking for is there. I think something else may be going on here? I guess I'll have to look at the source code for Ocra potentially to get a better idea of what is actually going on here. Though, I really do not understand C whatsoever, so that probably won't really be of much use?

Largo commented 3 years ago

Is it possible that you are running Ruby 2.7.3-1? I'm getting something similar after an upgrade from 2.7.2. I downgraded and it started working again.

Speak2Erase commented 3 years ago

I just checked, and I'm using 2.7.2.

Speak2Erase commented 3 years ago

I wonder, does ocra bundle in msvc ruby or msys2 ruby?

Largo commented 3 years ago

Update: I just added all dlls manually using --dll for now. things then work. (dont add libsqlite3-0.dll if you didnt install/need sqlite - more info see below) --dll libsqlite3-0.dll --dll ruby_builtin_dlls/libgmp-10.dll --dll ruby_builtin_dlls/libffi-7.dll --dll ruby_builtin_dlls/zlib1.dll --dll ruby_builtin_dlls/libiconv-2.dll --dll ruby_builtin_dlls\libssp-0.dll --dll ruby_builtin_dlls\libssl-1_1-x64.dll --dll ruby_builtin_dlls\libcrypto-1_1-x64.dll --dll ruby_builtin_dlls\libyaml-0-2.dll --dll ruby_builtin_dlls/libwinpthread-1.dll

Some of my observations:

If you want to use sqlite

call ridk exec pacman -S mingw-w64-x86_64-sqlite3 --noconfirm
call copy C:\Ruby27-x64\msys64\mingw64\bin\libsqlite3-0.dll C:\Ruby27-x64\bin

My command to compile including sqlite:

ocra file1.rb extrafile.rb classes\* --chdir-first --no-lzma --innosetup setup.iss --gem-full --add-all-core --icon  icon.ico --output build\temp\output.exe --dll libsqlite3-0.dll --dll ruby_builtin_dlls/libgmp-10.dll --dll ruby_builtin_dlls/libffi-7.dll --dll ruby_builtin_dlls/zlib1.dll --dll ruby_builtin_dlls/libiconv-2.dll --dll ruby_builtin_dlls\libssp-0.dll --dll ruby_builtin_dlls\libssl-1_1-x64.dll --dll ruby_builtin_dlls\libcrypto-1_1-x64.dll --dll ruby_builtin_dlls\libyaml-0-2.dll --dll ruby_builtin_dlls/libwinpthread-1.dll
--gem-full=openssl --gem-full=tzinfo-data

Current version of ocra is a bit janky, still very useful software though.

My ruby versions: 2.7.2 and 2.7.3 Update:On my local system with 2.7.2 from installed in may some dlls get detected automatically. on my docker container with 2.7.3 that doesn't work. I have reports of it not working in 2.7.2 as well.

CAMOBAP commented 3 years ago

@Largo thanks a lot for sharing this.

From my side I can add that some gems may require --dll ruby_builtin_dlls/libwinpthread-1.dll too, for example https://github.com/masamitsu-murase/seven_zip_ruby

damian-m-g commented 2 years ago

Thanks a lot everyone for the investigation. @Speak2Erase I went into the same issue tonight. Ocra will compile in both Ruby 3.1 x86 and Ruby 3.1 x64 (after adding fiber.so where it has to, see). But, only in x86 my script ran. In x64 it asked for zlib.so.

So I grabbed the unzip that Ocra does, and actually zlib.so is being included!!! So the error message is wrong and misdirects. So I saw @Largo and several other ppl talking about problems with the dlls (I also had to implement this solution) and ocurred to me to check the ruby_builtin_dlls directory. There are a couple of dlls, around 10. And one of those is: zlib1.dll. So I added that one with --dll ruby_builtin_dlls/zlib1.dll. And everything worked!!!

I suggest ocra to include all of this dlls, together they make ~4 MB. When you compile they become less than 1 MB. Or they could be taken into account if you select the --add-all-core option.

I hope this help someone. Cheers.

Speak2Erase commented 2 years ago

I believe ocra is no longer being maintained

damian-m-g commented 2 years ago

It's clunky but it still works. Maybe some day when I have plenty of extra time I can collab with the code, but that won't happen soon :/

Speak2Erase commented 2 years ago

I wouldn't mind maintaining something like this either, but I really don't have the time at the moment. I've got too many unfinished projects, annoyingly.

enumag commented 2 years ago

@damian-m-g Your comment just saved me. My compiled exe kept throwing an exception like this:

`require': 126: The specified module could not be found.
- C:/Users/Enumag/AppData/Local/Temp/ocr2D04.tmp/lib/ruby/gems/3.1.0/gems/zlib-2.1.1/lib/zlib.so (LoadError)

But adding --dll "ruby_builtin_dlls\zlib1.dll" finally fixed it!

Largo commented 2 years ago

UPDATE: see my fork ocranwhere this should not be necessary anymore

Ruby 3.1 Update with sqlite3:

call ridk exec pacman -S mingw-w64-x86_64-sqlite3 --noconfirm
copy C:\Ruby31-x64\msys64\mingw64\bin\libiconv-2.dll C:\Ruby31-x64\bin
copy C:\Ruby31-x64\msys64\mingw64\bin\libsqlite3-0.dll C:\Ruby31-x64\bin
ridk.cmd exec pacman -S mingw-w64-x86_64-ruby3.0.3-2 --noconfirm
copy C:\Ruby31-x64\msys64\mingw64\lib\ruby\3.0.0\x64-mingw32\fiber.so C:\Ruby31-x64\lib\ruby\3.1.0\x64-mingw-ucrt

ocra test.rb --dll libiconv-2.dll --dll libsqlite3-0.dll --dll ruby_builtin_dlls/libgmp-10.dll --dll ruby_builtin_dlls/libffi-7.dll --dll ruby_builtin_dlls/zlib1.dll --dll ruby_builtin_dlls/libssp-0.dll --dll ruby_builtin_dlls/libssl-1_1-x64.dll --dll ruby_builtin_dlls/libcrypto-1_1-x64.dll --dll ruby_builtin_dlls/libyaml-0-2.dll --dll ruby_builtin_dlls/libwinpthread-1.dll  --dll ruby_builtin_dlls/libgcc_s_seh-1.dll
Maximalist Example with Innosetup, OpenSSL and tzinfo-data Gems:

ocra test.rb --chdir-first --no-lzma --innosetup setup.iss --gem-full --add-all-core --icon  iconfile.ico --output test.exe --dll ruby_builtin_dlls/libgmp-10.dll --dll ruby_builtin_dlls/libffi-7.dll --dll ruby_builtin_dlls/zlib1.dll --dll ruby_builtin_dlls/libssp-0.dll --dll ruby_builtin_dlls/libssl-1_1-x64.dll --dll ruby_builtin_dlls/libcrypto-1_1-x64.dll --dll ruby_builtin_dlls/libyaml-0-2.dll --dll ruby_builtin_dlls/libwinpthread-1.dll  --dll libiconv-2.dll --dll libsqlite3-0.dll  --dll ruby_builtin_dlls/libgcc_s_seh-1.dll --gem-full=openssl --gem-full=tzinfo-data

TinyTds Users:
ridk exec pacman -S mingw-w64-ucrt-x86_64-freetds --noconfirm
gem install tiny_tds --with-freetds-include=C:\Ruby31-x64\msys64\ucrt64\include\freetds
copy C:\Ruby31-x64\msys64\ucrt64\bin\libsybdb-5.dll C:\Ruby31-x64\bin
Add the following flag:  --dll libsybdb-5.dll 

How I figured out which dll was missing? Open Sysinternals Process Explorer and compare ocra and regular ruby process > View > Show Lower Pane , Lower Pane View > DLLs

MohamedAliHabib commented 2 months ago

I came across multiple open issues (168, 184, and 174) due to the same cause. Proposed solutions, involving bundling missing DLLs, are inconsistent across environments, working for some but not others. In some cases, the code compiles, but the executable either crashes at runtime or runs and does nothing.

For those facing this issue, the solution mentioned above by @Largo includes a combination of DLLs that worked for Ruby 3.0.2 and Ocra 1.3.11. Interestingly, including all DLLs from /Ruby30-x64/bin/ruby_builtin_dlls still failed until I used this specific set of DLLs:

ocra example.rb --dll ruby_builtin_dlls/libiconv-2.dll --dll ruby_builtin_dlls/libgmp-10.dll --dll ruby_builtin_dlls/libffi-7.dll --dll ruby_builtin_dlls/zlib1.dll --dll ruby_builtin_dlls/libssp-0.dll --dll ruby_builtin_dlls/libssl-1_1-x64.dll --dll ruby_builtin_dlls/libcrypto-1_1-x64.dll --dll ruby_builtin_dlls/libyaml-0-2.dll --dll ruby_builtin_dlls/libwinpthread-1.dll  --dll ruby_builtin_dlls/libgcc_s_seh-1.dll --output example.exe
Speak2Erase commented 2 months ago

ocran is an actively maintained fork of ocra. For anyone else who stumbles onto this issue, you should try ocran instead!

enumag commented 2 months ago

There is also aibika. Though it seems the author is now working on tebako instead.

I have been using aibika for a while now after running to issues with ocra. Didn't try tebako yet.

Largo commented 2 months ago

ocran is an actively maintained fork of ocra. For anyone else who stumbles onto this issue, you should try ocran instead!

Thanks for the shoutout. We accept PRs as well!

The OCRAN gem is built using github actions for safety. We are currently aiming for a cross platform variant, which is possible using the same approach as the windows version.