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

Compile and bundle Nokogiri and its dependencies (liblzma) #1694

Closed
wilsonsilva opened this issue Nov 30, 2017 · 9 comments
Closed

Compile and bundle Nokogiri and its dependencies (liblzma) #1694

wilsonsilva opened this issue Nov 30, 2017 · 9 comments

Comments

@wilsonsilva
Copy link

wilsonsilva commented Nov 30, 2017

I have to compile and bundle Nokogiri v1.7.2 or v1.8.1 and all its dependencies to a single folder on MacOS and a single folder on CentOS. The main reason for this is that on the deployment machine I don't have access to /usr/local/lib. Everything needs to be self-contained.

I compiled the gem using:

gem install nokogiri --version 1.7.2 --install-dir $DEPLOYMMENT_PATH/vendor/gems/Darwin
gem install nokogiri --version 1.7.2 --install-dir $DEPLOYMMENT_PATH/vendor/gems/CentOS6

But I got this error (I edited the paths for the message to fit without scroll):

LoadError: dlopen(/gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.bundle, 9): Library not
 loaded: /usr/local/lib/liblzma.5.dylib
Referenced from: /gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 8.0.0 or later,
 but liblzma.5.dylib provides version 6.0.0

Copying liblzma.5.dylib to /usr/local/lib/ solves the issue, but it would be great if I could bundle that dependency in the Nokogiri gem folder instead. I tried to copy it to the lib and ext folders, but it still doesn't work.

Is it possible to compile Nokogiri with static linking to liblzma or at least provide a custom location that is not /usr/local/lib?

--enable-static doesn't work (invalid option: --enable-static).

My system:

  • MacOS Sierra 10.12.6 (16G29)
  • ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14] (using RVM)
  • RubyGems 2.6.12
@wilsonsilva wilsonsilva changed the title Compile and bundle Nokogiri and its dependencies Compile and bundle Nokogiri and its dependencies (liblzma) Nov 30, 2017
@FranklinYu
Copy link

Copying liblzma.5.dylib to /usr/local/lib/ solves the issue

So you didn't install the zlib there, did you?

@wilsonsilva
Copy link
Author

So you didn't install the zlib there, did you?

No. These are the contents of the destination /usr/local/lib folder:

lrwxrwxr-x  1 jenkins  admin      36 24 Sep  2015 engines -> ../Cellar/openssl/1.0.1h/lib/engines
lrwxrwxr-x  1 jenkins  admin      50 24 Sep  2015 libcrypto.1.0.0.dylib -> ../Cellar/openssl/1.0.1h/lib/libcrypto.1.0.0.dylib
lrwxrwxr-x  1 jenkins  admin      40 24 Sep  2015 libcrypto.a -> ../Cellar/openssl/1.0.1h/lib/libcrypto.a
lrwxrwxr-x  1 jenkins  admin      44 24 Sep  2015 libcrypto.dylib -> ../Cellar/openssl/1.0.1h/lib/libcrypto.dylib
-rwxr-xr-x  1 jenkins  admin  135172 24 Sep  2015 libpcre.1.dylib
-rw-r--r--  1 jenkins  admin  543800 24 Sep  2015 libpcre.a
lrwxr-xr-x  1 jenkins  admin      15 25 Sep  2015 libpcre.dylib -> libpcre.1.dylib
-rwxr-xr-x  1 jenkins  admin     909 24 Sep  2015 libpcre.la
-rwxr-xr-x  1 jenkins  admin   39744 24 Sep  2015 libpcrecpp.0.dylib
-rw-r--r--  1 jenkins  admin   52296 24 Sep  2015 libpcrecpp.a
lrwxr-xr-x  1 jenkins  admin      18 25 Sep  2015 libpcrecpp.dylib -> libpcrecpp.0.dylib
-rwxr-xr-x  1 jenkins  admin     953 24 Sep  2015 libpcrecpp.la
-rwxr-xr-x  1 jenkins  admin    9640 24 Sep  2015 libpcreposix.0.dylib
-rw-r--r--  1 jenkins  admin   11568 24 Sep  2015 libpcreposix.a
lrwxr-xr-x  1 jenkins  admin      20 25 Sep  2015 libpcreposix.dylib -> libpcreposix.0.dylib
-rwxr-xr-x  1 jenkins  admin     965 24 Sep  2015 libpcreposix.la
lrwxrwxr-x  1 jenkins  admin      47 24 Sep  2015 libssl.1.0.0.dylib -> ../Cellar/openssl/1.0.1h/lib/libssl.1.0.0.dylib
lrwxrwxr-x  1 jenkins  admin      37 24 Sep  2015 libssl.a -> ../Cellar/openssl/1.0.1h/lib/libssl.a
lrwxrwxr-x  1 jenkins  admin      41 24 Sep  2015 libssl.dylib -> ../Cellar/openssl/1.0.1h/lib/libssl.dylib

@FranklinYu
Copy link

Anyway, I think you may be able to install zlib in your deployment folder, then

gem install nokogiri -- --with-zlib-dir=/path/to/vendor/folder

@wilsonsilva
Copy link
Author

Nice! I didn't know that zlib and liblzma were interchangeable. Thanks. I'll try it.

@FranklinYu
Copy link

I'm actually familiar with neither. AFAIK, liblzma (part of XZ utilities is intended as drop-in replace of libz (and they claim better performance), so the compiler script tries liblzma before searching libz. According to my quick search.

@flavorjones
Copy link
Member

Sounds like this is resolved? I'll close in a few days unless I hear back.

@wilsonsilva
Copy link
Author

I had higher priorities, so I parked this issue until the new year. I didn't try it yet, but I hope that Frank's solution works.

@flavorjones
Copy link
Member

Bumping. @wilsonsilva have you had a chance to try @FranklinYu's suggestion?

@wilsonsilva
Copy link
Author

No, @flavorjones. This issue has been deprioritized. I won't work on this for the next month or two. Feel free to close it.

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

3 participants