larsch / ocra

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

fails to load libsass.so #165

Closed repu1sion closed 4 years ago

repu1sion commented 4 years ago

I have a script which contains require 'sassc' . I build executable with next command: ocra --verbose --debug --debug-extract --gem-full --add-all-core --gemfile Gemfile metanorma.rb Then run it and see next error:

Traceback (most recent call last):
        13: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/src/metanorma.rb:78:in `<main>'
        12: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/src/metanorma.rb:78:in `require'
        11: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/isodoc-1.0.6/lib/isodoc.rb:17:in `<top (required)>'
        10: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/isodoc-1.0.6/lib/isodoc.rb:17:in `require'
         9: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/isodoc-1.0.6/lib/isodoc/convert.rb:2:in `<top (requi
red)>'
         8: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/isodoc-1.0.6/lib/isodoc/convert.rb:2:in `require'
         7: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc.rb:31:in `
<top (required)>'
         6: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc.rb:31:in `
require_relative'
         5: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc/native.rb:
5:in `<top (required)>'
         4: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc/native.rb:
6:in `<module:SassC>'
         3: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc/native.rb:
11:in `<module:Native>'
         2: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/ffi-1.11.2-x64-mingw32/lib/ffi/library.rb:102:in `ff
i_lib'
         1: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/ffi-1.11.2-x64-mingw32/lib/ffi/library.rb:102:in `ma
p'
C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/ffi-1.11.2-x64-mingw32/lib/ffi/library.rb:162:in `block in ffi_lib':
 (LoadError)en library './libsass.so': The specified module could not be found.
        14: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/src/metanorma.rb:78:in `<main>'
        13: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/src/metanorma.rb:78:in `require'
        12: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/isodoc-1.0.6/lib/isodoc.rb:17:in `<top (required)>'
        11: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/isodoc-1.0.6/lib/isodoc.rb:17:in `require'
        10: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/isodoc-1.0.6/lib/isodoc/convert.rb:2:in `<top (requi
red)>'
         9: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/isodoc-1.0.6/lib/isodoc/convert.rb:2:in `require'
         8: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc.rb:31:in `
<top (required)>'
         7: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc.rb:31:in `
require_relative'
         6: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc/native.rb:
5:in `<top (required)>'
         5: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc/native.rb:
6:in `<module:SassC>'
         4: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc/native.rb:
10:in `<module:Native>'
         3: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/lib/sassc/native.rb:
13:in `rescue in <module:Native>'
         2: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/ffi-1.11.2-x64-mingw32/lib/ffi/library.rb:102:in `ff
i_lib'
         1: from C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/ffi-1.11.2-x64-mingw32/lib/ffi/library.rb:102:in `ma
p'
C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/gems/ffi-1.11.2-x64-mingw32/lib/ffi/library.rb:162:in `block in ffi_lib':
Could not open library 'C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/ext/libsass.so
 (LoadError)ified module could not be found.

So it looks like we can't find and load libsass.so But the lib itself is present on this path: C:/archive/develop/ocra/metanorma/ocr689A.tmp/lib/ruby/gems/2.6.0/bundler/gems/sassc-ruby-6e07d9634af0/ext/libsass.so It is around 2.4Mb and seems fine. The same script works fine in windows environment.

After some investigation it seems that ffi fails to load the dynamic library in ocra environment. In lib/ffi/library.rb we fail at this line: lib = FFI::DynamicLibrary.open(libname, lib_flags) It just calls corresponding C function from ffi_c.so , I guess it just calls somehow LoadLibrary() or LoadLibraryEx() inside to load .dll into memory of current process. All libs like ffi_c.so, libsass.so, x64-msvcrt-ruby260.dll, libffi-6.dll are present into ocra image (which I see after unpacking). What could be wrong? Maybe ocra misses some functionality which allows to load libraries via ffi? Or it fails to find some windows libraries like msvcrt.dll etc? Any help is welcome (1.3.11 ocra gem used).

repu1sion commented 4 years ago

my bad, libsass.so was customized before, ocra seems fine.