Maybe there's an easy workaround? I tried first installing an older version of ruby-xz gem install ruby-xz -v 0.1.1 but that didn't help.
$ docker run -ti centos:centos6 bash
# yum groupinstall -y "Development tools"
# yum install -y make gcc gawk ruby-devel rubygems
# gem install fpm
ERROR: Error installing fpm:
ruby-xz requires Ruby version >= 1.9.3.
To workaround, use older version of fpm on CentOS6:
# gem install fpm -v 1.4.0
Successfully installed fpm-1.4.0
1 gem installed
Bit me too. Seems like an unintended consequence of a gem dependency chain, not an actual 1.9 requirement.
ruby-xz is only used for FreeBSD packaging which is new in 1.5, and FreeBSD support is 2.0+ only. Everything else uses a shell invocation for compression (which tbh is bad...) and so works around the problem. Maybe it's time to just blanket support of specific modules in the way Logstash uses milestones kinda. 1.8.7 is quite ancient though, and while a few things are broken in 1.9.3, a fair bit more is broken in 1.8.7. Not much of a workaround here though, as I don't see anyone removing a feature for a version released over a decade ago and deprecated 3 years ago. Maybe it's possible to add something to the 1.5 gemfile that it requires 2.0 and newer.
On my CentOS6 machines I use ruby 1.9.3 from SCL, and I see different kind of failures, related to the absence of lzma libs required by ffi. I do have xz-libz listalled, which provides /usr/lib64/liblzma.so.0, but that seems not to be good enough:
/opt/rh/ruby193/root/usr/local/share/gems/gems/ffi-1.9.10/lib/ffi/library.rb:133:in
block in ffi_lib': Could not open library 'lzma.so.5': lzma.so.5: cannot open shared object file: No such file or directory. (LoadError) Could not open library 'liblzma.so.5': liblzma.so.5: cannot open shared object file: No such file or directory. Could not open library 'lzma.so': lzma.so: cannot open shared object file: No such file or directory. Could not open library 'liblzma.so': liblzma.so: cannot open shared object file: No such file or directory. Could not open library 'lzma': lzma: cannot open shared object file: No such file or directory from /opt/rh/ruby193/root/usr/local/share/gems/gems/ffi-1.9.10/lib/ffi/library.rb:100:inmap'
from /opt/rh/ruby193/root/usr/local/share/gems/gems/ffi-1.9.10/lib/ffi/library.rb:100:inffi_lib' from /opt/rh/ruby193/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz/lib_lzma.rb:84:inmodule:LibLZMA'
from /opt/rh/ruby193/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz/lib_lzma.rb:31:in<module:XZ>' from /opt/rh/ruby193/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz/lib_lzma.rb:28:infrom /opt/rh/ruby193/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz.rb:450:in require_relative' from /opt/rh/ruby193/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz.rb:450:infrom /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in require' from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:inrequire'
from /opt/rh/ruby193/root/usr/local/share/gems/gems/backports-3.6.8/lib/backports/std_lib.rb:9:inrequire_with_backports' from /opt/rh/ruby193/root/usr/local/share/gems/gems/fpm-1.5.0/lib/fpm/package/freebsd.rb:7:infrom /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in require' from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:inrequire'
from /opt/rh/ruby193/root/usr/local/share/gems/gems/backports-3.6.8/lib/backports/std_lib.rb:9:inrequire_with_backports' from /opt/rh/ruby193/root/usr/local/share/gems/gems/fpm-1.5.0/lib/fpm.rb:19:infrom /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in require' from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:inrequire'
from /opt/rh/ruby193/root/usr/local/share/gems/gems/fpm-1.5.0/bin/fpm:5:in<top (required)>' from /opt/rh/ruby193/root/usr/local/bin/fpm:23:inload'
from /opt/rh/ruby193/root/usr/local/bin/fpm:23:in `'
I also had @cristim's problem. I changed rubies because the default version of ruby that comes with centos:6 had a bug in a codepath i cared about (https://github.com/jordansissel/fpm/issues/923).
This is how I get FPM running on centos:6 (its from my dockerfile but you get the idea)
FROM centos:6
RUN yum -y install gcc make autoconf wget vim rpm-build
# Set up Ruby 1.9.3 for FPM.
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
RUN curl -L get.rvm.io | bash -s stable
ENV PATH /usr/local/rvm/gems/ruby-1.9.3-p551/bin:/usr/local/rvm/gems/ruby-1.9.3-p551@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p551/bin:/usr/local/rvm/bin:$PATH
RUN rvm install 1.9.3
RUN gem install fpm --version 1.4.0
notice i had to downgrade to 1.4.0 because of this issue.
thanks @moribellamy. Your fix helped me get this working on CentOS 6.6
thanks @moribellamy. Your fix also helped me get this working
A quick note for @cristim.
I have a similar situation except that my build machine has ruby 2.3.1 installed from source.
The ruby-xz gem loads lzma.so.5 which does not exist on a Cent OS 6 system but does exist in Amazon Linux system I have. The xz-libs version 5.1.2 package in Amazon Linux provides lzma.so.5.
Cent OS 6.7 packages xz-libs version 4.999.9 which provides liblzma.so.0, not liblzma.so.5. I'm not a UNIX shared library expert but it seems like the dependency is too old on Cent OS 6.
Downgrading my fpm to 1.4 eliminated my problem and may fix yours.
Possibly yeah. Does fpm still install on old CentOS systems despite asking for ruby-xz? Is it just a runtime issue?
Yes, I'm running on CentOS 6 with ruby-22 installed via scl.
I have the following gems installed —
[root@fmtgocddist01 ~]# gem list
*** LOCAL GEMS ***
archive-tar-minitar (0.5.2)
arr-pm (0.0.10)
backports (3.6.8)
bigdecimal (1.2.6)
bundler (1.7.8)
cabin (0.8.1)
childprocess (0.5.9)
clamp (1.0.0, 0.6.5)
ffi (1.9.10)
fpm (1.6.0, 1.4.0)
insist (1.0.0)
io-console (0.4.3)
io-like (0.3.0)
json (1.8.1)
mustache (0.99.8)
net-http-persistent (2.9.4)
pleaserun (0.0.24)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
ruby-xz (0.2.3)
stud (0.0.22)
thor (0.19.1)
FPM fails with the following trace, looks like it is ruby-xz-0.2.3 that is eventually trying to load liblzma
It appears like delaying loading of xz is the only solution for CentOS 6. I'm happy to submit a patch, if you like the idea in principle.
[root@fmtgocddist01 ~]# fpm -v
/opt/rh/rh-ruby22/root/usr/local/share/gems/gems/ffi-1.9.10/lib/ffi/library.rb:133:in `block in ffi_lib': Could not open library 'lzma.so.5': lzma.so.5: cannot open shared object file: No such file or directory. (LoadError)
Could not open library 'liblzma.so.5': liblzma.so.5: cannot open shared object file: No such file or directory.
Could not open library 'lzma.so': lzma.so: cannot open shared object file: No such file or directory.
Could not open library 'liblzma.so': liblzma.so: cannot open shared object file: No such file or directory.
Could not open library 'lzma': lzma: cannot open shared object file: No such file or directory
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/ffi-1.9.10/lib/ffi/library.rb:100:in `map'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/ffi-1.9.10/lib/ffi/library.rb:100:in `ffi_lib'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz/lib_lzma.rb:84:in `<module:LibLZMA>'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz/lib_lzma.rb:31:in `<module:XZ>'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz/lib_lzma.rb:28:in `<top (required)>'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz.rb:450:in `require_relative'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/ruby-xz-0.2.3/lib/xz.rb:450:in `<top (required)>'
from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/backports-3.6.8/lib/backports/std_lib.rb:9:in `require_with_backports'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/fpm-1.6.0/lib/fpm/package/freebsd.rb:6:in `<top (required)>'
from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/backports-3.6.8/lib/backports/std_lib.rb:9:in `require_with_backports'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/fpm-1.6.0/lib/fpm.rb:19:in `<top (required)>'
from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
from /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/fpm-1.6.0/bin/fpm:5:in `<top (required)>'
from /opt/rh/rh-ruby22/root/usr/local/bin/fpm:23:in `load'
from /opt/rh/rh-ruby22/root/usr/local/bin/fpm:23:in `<main>'
Ahh, thank you for the output there! I agree we can move the require for xz to just before fpm needs it, and that should help resolve most of this problem. +1
fpm 1.6.1 published with the fix (#1132). Thanks everyone for helping make this happen! <3
Most helpful comment
I also had @cristim's problem. I changed rubies because the default version of ruby that comes with centos:6 had a bug in a codepath i cared about (https://github.com/jordansissel/fpm/issues/923).
This is how I get FPM running on centos:6 (its from my dockerfile but you get the idea)
notice i had to downgrade to 1.4.0 because of this issue.