Largo / ocran

Turn ruby files into .exe files on windows (supported safe fork of ocran)
MIT License
53 stars 5 forks source link

Using rspec with OCRAN executable #22

Open divinity666 opened 1 month ago

divinity666 commented 1 month ago

Thanks a lot for this amazing software and keeping it alive! I am using is to build the executable of my open source ruby application and ship it for windows users.

I recognized, that OCRAN somehow does not seem to capture all relevant gems, though I really don't do any fancy stuff on require-ing. To solve this, I started mentioning explicit requires for missing parts, which then seems to work.

Unfortunately, I recognized, that it's not obvious, what might be missing, so I tried to include the OCRAN built in my automated test pipeline and wanted to call it via rspec and simple Kernel#system calls. And here comes the issue: I get random issues, telling me something with bundler is not correct, though calling the executable from console works out fine.

Could it be, that OCRAN mixes something up, when being called from rspec?

shinokaro commented 1 month ago

OCRAN is currently undergoing improvements for operation in Ruby 3 environments. We would greatly appreciate it if you could provide us with detailed information about any issues you are encountering while using OCRAN. Specifically, please include information about your Windows version and Ruby environment (OCRAN has been tested with Windows 10 and later, and Ruby 3.0 and later).

Could you possibly clone this repository and try the latest version of OCRAN? By executing the following command, you can compile the necessary binaries such as stub.exe for OCRAN:

rake build_stub

Using the --verbose option will log which files are being copied and the environment variables set at runtime.

Currently, OCRAN does not perfectly capture all required Gems. We are aware of issues related to the capture of default GEMs, rubygems, and bundler.

Please consider trying the --add-all-core and --gem-full options as well. These may help in resolving your issues.

divinity666 commented 1 month ago

In my build environment, I am using appveyor with image "Visual Studio 2022", which relies currently on Windows Server 2019 and Ruby 3.2.4-1 x64.

My local environment is Windows 11 with Ruby 3.3.1-x64.

Using the --add-all-core and --gem-full options does at least not solve my issue when running via rspec. I will try it on console command calls.

Why should building OCRAN myself help here? Is it a different version than the published one?

shinokaro commented 1 month ago

The latest version of the repository allows for detailed logging with the --verbose option, which can help identify where issues may be occurring. Additionally, you can use the --debug-extract option with the current version of OCRAN to extract files to the current directory when executing the executable.

It may or may not be relevant to you, but it is known that OCRAN1.3.15 does not operate correctly under bundle exec in environments using Ruby 3.2 or later. To address this, I am actively developing improvements for OCRAN.

Largo commented 1 month ago

@divinity666 The new version 1.3.16 is out. please try again with that one. thanks!

divinity666 commented 1 month ago

Thanks for giving me the heads up! I did not manage to build OCRAN myself in the meantime, so the new release is highly appreciated!

I just retried and can confirm that building the executable without --add-all-core and --gem-full seems to work now! Thanks a lot fot that!

Executing the executable from rspec with a simple system call does not work properly. Find here some outtake of the log:

Executing: ruby-grafana-reporter-0.9.3.exe -h
C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1480:in `rescue in block in activate_dependencies': Could not find 'matrix' (~> 0.4) among 83 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/gems;C:/Users/Christian/.gem/ruby/3.3.0' at: C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/gems/specifications/asciidoctor-pdf-2.3.18.gemspec, execute `gem env` for more information
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1477:in `block in activate_dependencies'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1466:in `each'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1466:in `activate_dependencies'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1448:in `activate'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems.rb:205:in `rescue in try_activate'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems.rb:198:in `try_activate'
    from <internal:C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:139:in `block in require'
    from <internal:C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:139:in `synchronize'
    from <internal:C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:139:in `rescue in require'
    from <internal:C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:135:in `require'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/src/lib/ruby_grafana_reporter.rb:22:in `<top (required)>'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/src/bin/ruby-grafana-reporter:4:in `require_relative'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/src/bin/ruby-grafana-reporter:4:in `<main>'
C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/dependency.rb:313:in `to_specs': Could not find 'matrix' (~> 0.4) among 83 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/gems;C:/Users/Christian/.gem/ruby/3.3.0' , execute `gem env` for more information
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1478:in `block in activate_dependencies'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1466:in `each'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1466:in `activate_dependencies'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1448:in `activate'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems.rb:205:in `rescue in try_activate'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems.rb:198:in `try_activate'
    from <internal:C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:139:in `block in require'
    from <internal:C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:139:in `synchronize'
    from <internal:C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:139:in `rescue in require'
    from <internal:C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:135:in `require'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/src/lib/ruby_grafana_reporter.rb:22:in `<top (required)>'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/src/bin/ruby-grafana-reporter:4:in `require_relative'
    from C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/src/bin/ruby-grafana-reporter:4:in `<main>'
C:/Users/Me/AppData/Local/Temp/ocran113D65E790BA/lib/ruby/3.3.0/rubygems/specification.rb:1480:in `rescue in block in activate_dependencies': Could not find 'matrix' (~> 0.4) among 83 total gem(s) (Gem::MissingSpecError)

Do you have any thoughts here?