kontena / pharos-cluster

Pharos - The Kubernetes Distribution
https://k8spharos.dev/
Apache License 2.0
312 stars 40 forks source link

(master) Binary can't load bcrypt_ext #823

Closed kke closed 5 years ago

kke commented 5 years ago

If you build the binary from master that includes #822 that brings in bcrypt which has native extensions, you get this:

$ pharos version # or any other command
...
Kontena Pharos:
  - pharos-cluster version 2.0.2
Traceback (most recent call last):
        24: from /__enclose_io_memfs__/lib/ruby/gems/2.5.0/bin/pharos-cluster:23:in `<main>'
....
/__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 commented 5 years ago

I made a pharos eval subcommand to investigate what's in the enclosed fs.

When I look at my local system:

$ ls -al /usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-16/2.5.0/bcrypt-3.1.12
total 72
drwxr-xr-x   5 kimmo  staff    160 Nov 21 09:59 .
drwxr-xr-x  21 kimmo  staff    672 Nov 21 09:59 ..
-rwxr-xr-x   1 kimmo  staff  29416 Nov 21 09:59 bcrypt_ext.bundle
-rw-r--r--   1 kimmo  staff      0 Nov 21 09:59 gem.build_complete
-rw-r--r--   1 kimmo  staff   2720 Nov 21 09:59 gem_make.out

But when I look inside the enclosed fs:

./pharclu eval -e "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

The same goes for the ed25519 native extensions, the local dir includes the binary ed25519_ref10.bundle and the enclose fs directory does not. It seems it isn't working either:

$ ./pharclu eval -e "require 'ed25519'" 
/__enclose_io_memfs__/lib/ruby/gems/2.5.0/gems/pharos-cluster-2.0.2/lib/pharos/eval_command.rb:8:in `eval': cannot load such file -- ed25519_ref10 (LoadError)

If I look at the rubyc temp dir after build, the bcrypt_ext.bundle is there, somehow it isn't copied into the binary.

When I look at the ruby-packer/compiler.rb, it does this:

Dir["#{@work_dir_inner}/**/*.{a,dylib,so,dll,lib,bundle}"].each do |thisdl|
  @utils.rm_f(thisdl)
end

Looks like it destroys the compiled extension from the squashfs.