ruby-packer icon indicating copy to clipboard operation
ruby-packer copied to clipboard

Native extensions are deleted during build and can not be used

Open kke opened this issue 7 years ago • 4 comments

Reference: https://github.com/kontena/pharos-cluster/issues/823#issuecomment-440645953

It's entirely possible that I don't understand the build process correctly, but to me it seems like https://github.com/pmq20/ruby-packer/blob/master/lib/compiler.rb#L860-L862 is deleting all the *.{a,dylib,so,dll,lib,bundle} from the squashfs filesystem, which, I believe, include the compiled output of native extensions?

When I look inside the squashfs, I can see the gem extension dir indeed does not contain the *.bundle:

puts Dir.glob('/__enclose_io_memfs__/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/bcrypt-3.1.12/**/*').join($/)
/__enclose_io_memfs__/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/bcrypt-3.1.12/gem.build_complete
/__enclose_io_memfs__/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/bcrypt-3.1.12/gem_make.out

On my local system there's bcrypt_ext.bundle in there too.

And as it is not there in the squashfs, if I do require 'bcrypt', which does require 'bcrypt_ext', the program dies and says:

/__enclose_io_memfs__/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bcrypt_ext (LoadError)

kke avatar Nov 21 '18 12:11 kke

Can confirm that modifying the lines referenced above to skip ruby extension directories does fix the problem.

kke avatar Nov 23 '18 09:11 kke

did you use rubyc version v0.4.0?

iamsimakov avatar Nov 23 '18 16:11 iamsimakov

@iamsimakov No, one compiled from master.

kke avatar Nov 26 '18 06:11 kke

so, just try it, master branch is unstable maybe ) @kke

iamsimakov avatar Nov 26 '18 16:11 iamsimakov