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:
Copying
liblzma.5.dylibto/usr/local/lib/solves the issue
So you didn't install the zlib there, did you?
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
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
Nice! I didn't know that zlib and liblzma were interchangeable. Thanks. I'll try it.
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.
Sounds like this is resolved? I'll close in a few days unless I hear back.
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.
Bumping. @wilsonsilva have you had a chance to try @franklinyu's suggestion?
No, @flavorjones. This issue has been deprioritized. I won't work on this for the next month or two. Feel free to close it.