rubywatirocra

OCRA cant convert ruby to exe


the code executed perfectly, however, it's taking forever to process this simple code

require 'watir'
browser = Watir::Browser.new :firefox
browser.goto "https://google.com"

and this is the command line logs for the OCRA process, i had to exit the code via CTRL+C as i left it for an hour and never produced any results. any ideas ?

=== Loading script to check dependencies
=== Attempting to trigger autoload of Gem::ConfigFile
=== Attempting to trigger autoload of Gem::DependencyList
=== Attempting to trigger autoload of Gem::DependencyResolver
=== Attempting to trigger autoload of Gem::Installer
=== Attempting to trigger autoload of Gem::Licenses
=== Attempting to trigger autoload of Gem::Source
=== Attempting to trigger autoload of Gem::RequestSet
=== Attempting to trigger autoload of Gem::SpecFetcher
=== Attempting to trigger autoload of Gem::SourceList
=== Attempting to trigger autoload of RubyInstaller::Runtime::Components::Base
=== WARNING: RubyInstaller::Runtime::Components::Base was defined autoloadable,
but caused NameError
=== Attempting to trigger autoload of RubyInstaller::Runtime::Colors
=== Attempting to trigger autoload of RubyInstaller::Runtime::ComponentsInstalle
r
=== Attempting to trigger autoload of RubyInstaller::Runtime::Ridk
=== Attempting to trigger autoload of RubyInstaller::Runtime::PACKAGE_VERSION
=== Attempting to trigger autoload of Selenium::WebDriver::Chrome
=== Attempting to trigger autoload of Selenium::WebDriver::Edge
=== Attempting to trigger autoload of Selenium::WebDriver::IE
=== Attempting to trigger autoload of Selenium::WebDriver::PhantomJS
=== WARNING: Selenium::WebDriver::PhantomJS was not loadable
=== Attempting to trigger autoload of Selenium::WebDriver::Safari
=== Attempting to trigger autoload of Selenium::WebDriver::Support
=== Attempting to trigger autoload of CGI::HtmlExtension
=== Detected gem did_you_mean-1.1.0 (loaded, files)
===     14 files, 32780 bytes
=== Detected gem ocra-1.3.10 (loaded, files)
===     5 files, 210830 bytes
=== Detected gem rubyzip-1.2.1 (loaded, files)
===     36 files, 92674 bytes
=== Detected gem ffi-1.9.25-x64-mingw32 (loaded, files)
===     70 files, 1785972 bytes
=== Detected gem childprocess-0.9.0 (loaded, files)
===     19 files, 43107 bytes
=== Detected gem selenium-webdriver-3.13.0 (loaded, files)
===     120 files, 1191026 bytes
=== Detected gem watir-6.11.0 (loaded, files)
===     97 files, 280749 bytes
=== Detected gem json-2.1.0 (loaded, files)
===     37 files, 1721174 bytes
=== Detected gem openssl-2.0.7 (loaded, files)
=== WARNING: Gem openssl-2.0.7 root folder was not found, skipping
=== Detected gem psych-2.2.2 (loaded, files)
=== WARNING: Gem psych-2.2.2 root folder was not found, skipping
=== Detected gem watir-scroll-0.4.0 (loaded, files)
===     9 files, 4494 bytes
=== Detected gem io-console-0.4.6 (loaded, files)
=== WARNING: Gem io-console-0.4.6 root folder was not found, skipping
=== Detected gem rake-12.0.0 (loaded, files)
===     43 files, 111973 bytes
=== Including 59 encoding support files (3909616 bytes, use --no-enc to exclude)

Solution

  • What ruby version are you using? I tried your code with 2.3.3 and the gem you required but i get some errors..

    For OCRA you can try these parameters when you build your exe:

    ocra script.rb --no-autoload --add-all-core

    If it's a windowed application instead try this:

    ocra script.rb --no-autoload --add-all-core --windows C:\Ruby23-x64\lib\tcltk\

    --add-all-core => Add all core ruby libraries to the executable.

    --no-autoload => Don't load/include script.rb's autoloads.

    --windows <path-to-gui-folder> => Force Windows application (rubyw.exe)

    If it works without --add-all-core, don't add it, so your exe will be lighter.. Hope it can help you!

    From the OCRA git page:

    Use $:.unshift File.dirname($0) at the start of your script if you need to 'require' additional source files from the same directory as your main script.

    If you need to add your files to the exe you can just add them at the end of the command line like this:

    ocra script.rb --no-autoload --add-all-core src/**/* files/boo.txt