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

Rails/OSX sample: fails to run on a separate OSX machine (nokogiri.bundle, Library not loaded) #1

Open
dennislysenko opened this issue Sep 28, 2016 · 4 comments

Comments

@dennislysenko
Copy link

Hello!

Fantastic library here! I'm having some trouble though. macOS Sierra, ruby 2.2.2, rails 5.0.0.1 -- I've created a new rails project (rails new ExecutableTest). I've compiled it into an executable using rb2exe --rails --target=osx, which works fantastically on my local machine. (There are a few more intricacies relating to getting it to use Sqlite3 db, I basically had to pass the path to the db as an environment variable containing the absolute path so I could use the executable from anywhere.)

When I try to run it on a Parallels VM of macOS Sierra I just spun up, however, I get this error:

os-x-10:Desktop jaqen$ DB_PATH=`pwd`/release.sqlite3 ./output 
/tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.8/lib/nokogiri.rb:32:in `require': dlopen(/tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.8/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /usr/local/opt/libxml2/lib/libxml2.2.dylib (LoadError)
  Referenced from: /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.8/lib/nokogiri/nokogiri.bundle
  Reason: Incompatible library version: nokogiri.bundle requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.8/lib/nokogiri/nokogiri.bundle
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.8/lib/nokogiri.rb:32:in `rescue in <top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.8/lib/nokogiri.rb:28:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/loofah-2.0.3/lib/loofah.rb:3:in `require'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/loofah-2.0.3/lib/loofah.rb:3:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/rails-html-sanitizer-1.0.3/lib/rails-html-sanitizer.rb:2:in `require'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/rails-html-sanitizer-1.0.3/lib/rails-html-sanitizer.rb:2:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/sanitize_helper.rb:2:in `require'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/sanitize_helper.rb:2:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/text_helper.rb:32:in `<module:TextHelper>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/text_helper.rb:29:in `<module:Helpers>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/text_helper.rb:6:in `<module:ActionView>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/text_helper.rb:4:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/form_tag_helper.rb:18:in `<module:FormTagHelper>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/form_tag_helper.rb:14:in `<module:Helpers>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/form_tag_helper.rb:8:in `<module:ActionView>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/form_tag_helper.rb:6:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/form_helper.rb:4:in `require'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers/form_helper.rb:4:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers.rb:50:in `<module:Helpers>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers.rb:4:in `<module:ActionView>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/actionview-5.0.0.1/lib/action_view/helpers.rb:3:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/context.rb:7:in `<module:Context>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/context.rb:6:in `<module:Rails>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/context.rb:5:in `<module:Sprockets>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/context.rb:4:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/railtie.rb:7:in `require'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sprockets-rails-3.2.0/lib/sprockets/railtie.rb:7:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sass-rails-5.0.6/lib/sass/rails/railtie.rb:3:in `require'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sass-rails-5.0.6/lib/sass/rails/railtie.rb:3:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sass-rails-5.0.6/lib/sass/rails.rb:11:in `require'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sass-rails-5.0.6/lib/sass/rails.rb:11:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sass-rails-5.0.6/lib/sass-rails.rb:1:in `require'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/sass-rails-5.0.6/lib/sass-rails.rb:1:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:76:in `require'
    from /tmp/selfextract.hRLsK1/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /tmp/selfextract.hRLsK1/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:72:in `each'
    from /tmp/selfextract.hRLsK1/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:72:in `block in require'
    from /tmp/selfextract.hRLsK1/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:61:in `each'
    from /tmp/selfextract.hRLsK1/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:61:in `require'
    from /tmp/selfextract.hRLsK1/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler.rb:134:in `require'
    from /private/tmp/selfextract.hRLsK1/lib/app/config/application.rb:7:in `<top (required)>'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /tmp/selfextract.hRLsK1/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:9:in `require'
    from bin/rails:9:in `<main>'
os-x-10:Desktop jaqen$ 

Any ideas? Perhaps I am misunderstanding the use-case here...is rb2exe meant to make a redistributable binary of a ruby program (incl rails server)? Or perhaps I need to take some extra step to properly precompile libxml2 for nokogiri? Any response is appreciated.

@dennislysenko dennislysenko changed the title Rails example: fails to run on a separate machine Rails/OSX sample: fails to run on a separate OSX machine (nokogiri.bundle, Library not loaded) Sep 28, 2016
@loureirorg
Copy link
Collaborator

Hi @dennislysenko.

Can you please compile with this environment variable:

export NOKOGIRI_USE_SYSTEM_LIBRARIES=1
rb2exe --rails --target=osx

Then, please let me know if works.

@dennislysenko
Copy link
Author

Thanks for the response! I did that and tried it on my parallels VM again, and got a similar error with a smaller stacktrace:

os-x-10:Desktop jaqen$ DB_PATH=`pwd`/release.sqlite3 ./output 
/tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `require': dlopen(/tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /usr/local/opt/libxml2/lib/libxml2.2.dylib (LoadError)
  Referenced from: /tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
  Reason: Incompatible library version: nokogiri.bundle requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
    from /tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `<top (required)>'
    from /tmp/selfextract.ErG61U/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:76:in `require'
    from /tmp/selfextract.ErG61U/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /tmp/selfextract.ErG61U/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:72:in `each'
    from /tmp/selfextract.ErG61U/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:72:in `block in require'
    from /tmp/selfextract.ErG61U/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:61:in `each'
    from /tmp/selfextract.ErG61U/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:61:in `require'
    from /tmp/selfextract.ErG61U/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler.rb:134:in `require'
    from /private/tmp/selfextract.ErG61U/lib/app/config/application.rb:7:in `<top (required)>'
    from /tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
    from /tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
    from /tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
    from /tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
    from /tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /tmp/selfextract.ErG61U/lib/vendor/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:9:in `require'
    from bin/rails:9:in `<main>'

As you can see I also tried downgrading nokogiri versions to the minimum for rails 5, which unfortunately didn't work either.

@dennislysenko
Copy link
Author

dennislysenko commented Sep 28, 2016

Here is some context about my development machine. I think based on the stack trace on the VM, it is trying to load my homebrew install of libxml2 rather than a bundled one, finding that this doesn't exist on the VM, and falling back to /usr/lib/libxml2.2.dylib which only provides version 10.0.0 on macOS sierra (on both my VM and my development machine.)

[~/dev/ExecutableTest_RBA]$ otool -L /usr/lib/libxml2.2.dylib                                                                                                                                                                                             [master][ruby-2.2.2]
/usr/lib/libxml2.2.dylib:
    /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
    /usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 57.1.0)
    /usr/lib/liblzma.5.dylib (compatibility version 6.0.0, current version 6.3.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
[~/dev/ExecutableTest_RBA]$ otool -L /usr/local/opt/libxml2/lib/libxml2.2.dylib                                                                                                                                                                           [master][ruby-2.2.2]
/usr/local/opt/libxml2/lib/libxml2.2.dylib:
    /usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version 12.0.0, current version 12.4.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

@dennislysenko
Copy link
Author

Perhaps using the traveling ruby prepackaged nokogiri could help circumvent this issue? Not entirely sure myself.

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

2 participants