larsch / ocra

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

Issue with Ocra and win32/api #192

Open concaho opened 1 year ago

concaho commented 1 year ago

Hi Guys, Need your help because I am blocked with a strange issue. I can't make an Exe with require("au3") in a rb file. I think the problem comes from au3 is depending of win32/api So I did a reproducer with win32/api.

OCRA was able a long time ago to make the script. But I had the ruby 2.3.0...

See a little reproducer: Create a .rb file with these lines;

beginningofthescript

puts ENV['GEM_PATH'] ENV['GEM_PATH']='C:/Ruby30/lib/ruby/gems/3.0.0' ENV['GEM_HOME']='C:/Ruby30/lib/ruby/gems/3.0.0' Gem.clear_paths puts ENV['GEM_PATH']

require("win32/api")

Endofthescript

C:\Users\concaho>ruby LaunchWorkstationTest.rb

C:/Ruby30/lib/ruby/gems/3.0.0

C:\Users\concaho>

Do the same with ocra: C:\Users\concaho>ocra LaunchWorkstationTest.rb === Loading script to check dependencies

C:/Ruby30/lib/ruby/gems/3.0.0 === Detected gem etc-1.3.0 (loaded, files) === 0 files, 0 bytes === Detected gem did_you_mean-1.5.0 (loaded, files) === 0 files, 0 bytes === Detected gem ocra-1.3.11 (loaded, files) === 5 files, 271800 bytes === Detected gem win32-api-1.10.1-universal-mingw32 (loaded, files) === 29 files, 1112578 bytes === Including 61 encoding support files (3707392 bytes, use --no-enc to exclude) === Building LaunchWorkstationTest.exe === Adding user-supplied source files === Adding ruby executable ruby.exe === Adding detected DLL C:/Ruby30/bin/ruby_builtin_dlls/libgmp-10.dll === Adding detected DLL C:/Ruby30/bin/ruby_builtin_dlls/libgcc_s_dw2-1.dll === Adding detected DLL C:/Ruby30/msys32/mingw32/bin/libssp-0.dll === Adding detected DLL C:/Ruby30/bin/ruby_builtin_dlls/libwinpthread-1.dll === Adding detected DLL C:/Ruby30/bin/ruby_builtin_dlls/libffi-8.dll === Adding external manifest C:/Ruby30/bin/ruby_builtin_dlls/ruby_builtin_dlls.manifest === Adding library files === Compressing 11024601 bytes

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

Input size: 11024601 (10 MiB) Output size: 2594406 (2 MiB) === Finished building LaunchWorkstationTest.exe (2645114 bytes)

Launch now the LaunchWorkstationTest.exe:

C:\Users\concaho>LaunchWorkstationTest.exe
C:\Users\concaho~1\AppData\Local\Temp\1\ocr6FA7.tmp\gemhome
C:/Ruby30/lib/ruby/gems/3.0.0
<internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- C:/Ruby30/lib/ruby/gems/3.0.0/gems/win32-api-1.10.1-universal-mingw32/lib/win32/../../ext/api (LoadError)
        from <internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/win32-api-1.10.1-universal-mingw32/lib/win32/api.rb:79:in `rescue in <top (required)>'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/win32-api-1.10.1-universal-mingw32/lib/win32/api.rb:2:in `<top (required)>'
        from <internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
        from <internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
        from <internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:149:in `require'
        from C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/src/LaunchWorkstationTest.rb:7:in `<main>'
<internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': 126: The specified module could not be found.   - C:/Ruby30/lib/ruby/gems/3.0.0/gems/win32-api-1.10.1-universal-mingw32/lib/win32/ruby30_32/win32/api.so (LoadError)
        from <internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from C:/Ruby30/lib/ruby/gems/3.0.0/gems/win32-api-1.10.1-universal-mingw32/lib/win32/api.rb:73:in `<top (required)>'
        from <internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
        from <internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
        from <internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:149:in `require'
        from C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/src/LaunchWorkstationTest.rb:7:in `<main>'
<internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- win32/api (LoadError)
        from <internal:C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from C:/Users/concaho~1/AppData/Local/Temp/1/ocr6FA7.tmp/src/LaunchWorkstationTest.rb:7:in `<main>'

C:\Users\concaho>

Coud you help me ? Or find a way to make an executable ? Thanks a lot!

Gem ENV: RubyGems Environment:

Concaho

concaho commented 1 year ago

Hi All, I found a workaround. I don't have this error with gem win32-api (1.4.0) instead of win32-api-1.10.1-universal-mingw32. It does not work with win32-api-1.5.0-universal-mingw32. As you can see it only works with package without the mingw32: win32-api (1.10.1 universal-mingw32, 1.5.0 universal-mingw32, 1.4.0) Thanks, Concaho