Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error loading nokogiri when starting compiled binary #151

Open
tonchev-ivan opened this issue Feb 12, 2021 · 14 comments
Open

Error loading nokogiri when starting compiled binary #151

tonchev-ivan opened this issue Feb 12, 2021 · 14 comments

Comments

@tonchev-ivan
Copy link

I am having troubles packing new rails application (generated just with rails new) which has dependency to nokogiri . I have tried configuring bundler options in compiler.rb with no success, tried any combinations of those:

      @utils.run(local_toolchain_env, @bundle, 'config', 'build.nokogiri', '--use-system-libraries', "true")
      @utils.run(local_toolchain_env, @bundle, 'config', 'set', 'deployment', "true")
      @utils.run(local_toolchain_env, @bundle, 'config', 'set', 'without', "'development test'")

Log message:

/__enclose_io_memfs__/local/vendor/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:324:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)

Note: If I dont use change bundler config I get the same error for sqlite3 gem.

Env info:
rubyc - latest master
os - 20.04.1-Ubuntu
ruby - 2.7.1 (rbenv)
rails - 6.0.3.4

@omohokcoj
Copy link

@tonchev-ivan did you remove bootsnap from your rails app?
Bootsnap doesnt work in ruby packer and it breaks native extensions loading.

@kritik
Copy link

kritik commented Oct 5, 2021

@omohokcoj I have removed bootsnap but I'm still getting an error on macOS.

Traceback (most recent call last):
	33: from /__enclose_io_memfs__/local/bin/rails:4:in `<main>'
	32: from /__enclose_io_memfs__/local/bin/rails:4:in `require'
	31: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands.rb:18:in `<top (required)>'
	30: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/command.rb:46:in `invoke'
	29: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/command/base.rb:69:in `perform'
	28: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	27: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	26: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	25: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands/server/server_command.rb:138:in `perform'
	24: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands/server/server_command.rb:138:in `tap'
	23: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands/server/server_command.rb:141:in `block in perform'
	22: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	21: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	20: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	19: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	18: from /__enclose_io_memfs__/local/config/application.rb:12:in `<top (required)>'
	17: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	16: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	15: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	14: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	13: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/actiontext/lib/action_text/engine.rb:8:in `<top (required)>'
	12: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	11: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	10: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	 9: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	 8: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/actiontext/lib/action_text.rb:6:in `<top (required)>'
	 7: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	 6: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	 5: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	 4: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	 3: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/nokogiri-1.12.4-x86_64-darwin/lib/nokogiri.rb:11:in `<top (required)>'
	 2: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/nokogiri-1.12.4-x86_64-darwin/lib/nokogiri.rb:11:in `require_relative'
	 1: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/nokogiri-1.12.4-x86_64-darwin/lib/nokogiri/extension.rb:7:in `<top (required)>'
/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/nokogiri-1.12.4-x86_64-darwin/lib/nokogiri/extension.rb:7:in `require_relative': cannot load such file -- /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/nokogiri-1.12.4-x86_64-darwin/lib/nokogiri/2.7/nokogiri (LoadError)
	37: from /__enclose_io_memfs__/local/bin/rails:4:in `<main>'
	36: from /__enclose_io_memfs__/local/bin/rails:4:in `require'
	35: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands.rb:18:in `<top (required)>'
	34: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/command.rb:46:in `invoke'
	33: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/command/base.rb:69:in `perform'
	32: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	31: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	30: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	29: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands/server/server_command.rb:138:in `perform'
	28: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands/server/server_command.rb:138:in `tap'
	27: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands/server/server_command.rb:141:in `block in perform'
	26: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	25: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	24: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	23: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	22: from /__enclose_io_memfs__/local/config/application.rb:12:in `<top (required)>'
	21: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	20: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	19: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	18: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	17: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/actiontext/lib/action_text/engine.rb:8:in `<top (required)>'
	16: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	15: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	14: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	13: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	12: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/actiontext/lib/action_text.rb:6:in `<top (required)>'
	11: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	10: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	 9: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	 8: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	 7: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/nokogiri-1.12.4-x86_64-darwin/lib/nokogiri.rb:11:in `<top (required)>'
	 6: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/nokogiri-1.12.4-x86_64-darwin/lib/nokogiri.rb:11:in `require_relative'
	 5: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/nokogiri-1.12.4-x86_64-darwin/lib/nokogiri/extension.rb:4:in `<top (required)>'
	 4: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/nokogiri-1.12.4-x86_64-darwin/lib/nokogiri/extension.rb:30:in `rescue in <top (required)>'
	 3: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	 2: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	 1: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
/__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)

@omohokcoj
Copy link

@kritik it looks like you need to remove the following lines from the complile.rb file:
motor-admin@dd10cc2#diff-a67b64a1d376c4e42cc056616662c72abd161952b3799ced47c68a4a0c05db0aR332

You can try my working ruby-packer fork https://github.com/motor-admin/ruby-packer - https://github.com/motor-admin/motor-admin has been packed into a single binary with it without any issues.

@kritik
Copy link

kritik commented Oct 6, 2021

@omohokcoj Thanks. That works much better. But why did you change binaries?

@omohokcoj
Copy link

@kritik I assume you're referring to the linked extensions replaced in the ruby-packer fork?
I compiled pg and mysql2 native extensions using static linker to make the executable even more portable and not depend on the libpq and libmysqlclient installation on the system (so no need to ask users to run apt-get install libpq-dev in order to run the executable).

@kritik
Copy link

kritik commented Oct 6, 2021

I see

@kritik
Copy link

kritik commented Oct 6, 2021

@omohokcoj my nokogiri problem has been resolved but I see another C-extension issue. Any idea how to resolve this one?

Traceback (most recent call last):
	44: from /__enclose_io_memfs__/local/bin/rails:4:in `<main>'
	43: from /__enclose_io_memfs__/local/bin/rails:4:in `require'
	42: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands.rb:18:in `<top (required)>'
	41: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/command.rb:46:in `invoke'
	40: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/command/base.rb:69:in `perform'
	39: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	38: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	37: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	36: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands/server/server_command.rb:138:in `perform'
	35: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands/server/server_command.rb:138:in `tap'
	34: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/railties/lib/rails/commands/server/server_command.rb:141:in `block in perform'
	33: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	32: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	31: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	30: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	29: from /__enclose_io_memfs__/local/config/application.rb:20:in `<top (required)>'
	28: from /__enclose_io_memfs__/lib/ruby/2.7.0/bundler.rb:174:in `require'
	27: from /__enclose_io_memfs__/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
	26: from /__enclose_io_memfs__/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
	25: from /__enclose_io_memfs__/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require'
	24: from /__enclose_io_memfs__/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each'
	23: from /__enclose_io_memfs__/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require'
	22: from /__enclose_io_memfs__/lib/ruby/2.7.0/bundler/runtime.rb:74:in `require'
	21: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/ups-ruby-a93c0d76a8dd/lib/ups-ruby.rb:2:in `<top (required)>'
	20: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	19: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	18: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	17: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	16: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/ups-ruby-a93c0d76a8dd/lib/ups.rb:1:in `<top (required)>'
	15: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/ups-ruby-a93c0d76a8dd/lib/ups.rb:12:in `<module:UPS>'
	14: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	13: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	12: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	11: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	10: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/ups-ruby-a93c0d76a8dd/lib/ups/data.rb:1:in `<top (required)>'
	 9: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	 8: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:291:in `load_dependency'
	 7: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `block in require'
	 6: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/bundler/gems/rails-396a51ad8196/activesupport/lib/active_support/dependencies.rb:324:in `require'
	 5: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/levenshtein.rb:3:in `<top (required)>'
	 4: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/levenshtein.rb:4:in `<module:Levenshtein>'
	 3: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/levenshtein.rb:10:in `singleton class'
	 2: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/ffi-1.13.1/lib/ffi/library.rb:99:in `ffi_lib'
	 1: from /__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/ffi-1.13.1/lib/ffi/library.rb:99:in `map'
/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/ffi-1.13.1/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library '/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/../ext/levenshtein/levenshtein.bundle': dlopen(/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/../ext/levenshtein/levenshtein.bundle, 5): image not found. (LoadError)
Could not open library '/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/../ext/levenshtein/levenshtein.so': dlopen(/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/../ext/levenshtein/levenshtein.so, 5): image not found.
Could not open library '/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/../ext/levenshtein/levenshtein.dylib': dlopen(/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/../ext/levenshtein/levenshtein.dylib, 5): image not found.
Could not open library '/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/../ext/levenshtein/levenshtein': dlopen(/__enclose_io_memfs__/lib/ruby/gems/2.7.0/gems/levenshtein-ffi-1.1.0/lib/../ext/levenshtein/levenshtein, 5): image not found

@omohokcoj
Copy link

@kritik ruby packer packs compiled dynamic libs (.so for linux and .bundle for macos) into a squashfs - but the problem is that dlopen doesn't work in the virtual filesystem.
So the solution was to copy .so .bundle files into the temp folder on disk to make the loading of dynamic libraries possible from there - but it looks like the ruby-packer C code responsible for this has a bug and sometimes files are not copies/loaded.

To fix that I had to override the Kernel#require method to check if it's loading .so/bundle file and copy it to the /tmp folder if so.

You can check the code here:
https://github.com/motor-admin/motor-admin/blob/master/config/boot.rb#L29

This monkey patch also solves the issue with slow app boot - #160

@kritik
Copy link

kritik commented Oct 6, 2021

@omohokcoj Thanks a lot. It helped but seems I far away from getting this done.

@kritik
Copy link

kritik commented Oct 6, 2021

Seems it's not gonna work for me. :( I'm getting now:
activesupport/lib/active_support/deprecation/proxy_wrappers.rb:172:in method_missing': private method warn' called for nil:NilClass (NoMethodError) - fixed by making warn method public in boot.rb :)
activesupport/lib/active_support/inflector/methods.rb:275:in `const_get': wrong constant name

@omohokcoj
Copy link

@kritik https://github.com/motor-admin/motor-admin/blob/master/config/boot.rb#L29 - i had to warn you that the require method monkey patch is not reliable and probably works only for my application.

You can try to remove the monkey patch for .rb files and use it only for .so and .bundle files:
https://github.com/motor-admin/motor-admin/blob/master/config/boot.rb#L16 - remove .rb extension from here but keep so/bundle

This might help but will make the app boot time very slow - up to 30 seconds.

@kritik
Copy link

kritik commented Oct 6, 2021

Thanks for your help. I have marked that you also cache rb files. :) Unfortunately removing rb file from caching didn't help me.

@ericbeland
Copy link

@omohokcoj Could we have permission to use the monkey patches in that file under MIT license?

@omohokcoj
Copy link

@ericbeland sure, feel free to reuse those monkey patches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants