tl;dr, the binaries in image_optim_pack were probably built against a newer system than the one you are trying to run it on. Try finding the latest version of image_optim_pack that works on your system. For me, the following versions worked:
gem "image_optim", "~> 0.25"
gem "image_optim_pack", "= 0.2.3"
More details
To get information on what piece is failing, run:
$ bundle exec image_optim --info
I see something like this:
$ bundle exec image_optim --info
image_optim v0.26.1
config:
verbose: true
nice: 10
threads: 4
pack: true
skip_missing_workers: true
allow_lossy: false
cache_dir:
cache_worker_digests: false
image_optim_pack: jpeg-recompress, jpegoptim, jhead, advpng, jpegtran, gifsicle, pngcrush, optipng from /path/to/gems/ruby-2.4.0/gems/image_optim_pack-0.5.0.20180419-x86_64-linux/vendor/linux-x86_64 failed
No pack for this OS and/or ARCH, check verbose output
Resolved jpegrescan 1a762f62 at /path/to/gems/ruby-2.4.0/gems/image_optim-0.26.1/vendor/jpegrescan
pngcrush worker: `pngcrush` not found; please provide proper binary or disable this worker (--no-pngcrush argument or `:pngcrush => false` through options)
pngout worker: `pngout` not found; please provide proper binary or disable this worker (--no-pngout argument or `:pngout => false` through options)
advpng worker: `advpng` not found; please provide proper binary or disable this worker (--no-advpng argument or `:advpng => false` through options)
optipng worker: `optipng` not found; please provide proper binary or disable this worker (--no-optipng argument or `:optipng => false` through options)
pngquant worker: `pngquant` not found; please provide proper binary or disable this worker (--no-pngquant argument or `:pngquant => false` through options)
jhead worker: `jhead` not found, `jpegtran` not found; please provide proper binary or disable this worker (--no-jhead argument or `:jhead => false` through options)
jpegoptim worker: `jpegoptim` not found; please provide proper binary or disable this worker (--no-jpegoptim argument or `:jpegoptim => false` through options)
jpegtran worker: `jpegtran` not found; please provide proper binary or disable this worker (--no-jpegtran argument or `:jpegtran => false` through options)
gifsicle worker: `gifsicle` not found; please provide proper binary or disable this worker (--no-gifsicle argument or `:gifsicle => false` through options)
svgo worker: `svgo` not found; please provide proper binary or disable this worker (--no-svgo argument or `:svgo => false` through options)
Workers by format:
It doesn't say why the workers failed. But you can run the worker binaries to find out:
# Path from the error message:
$ export IMAGE_OPTIM_BIN="/path/to/gems/ruby-2.4.0/gems/image_optim_pack-0.5.0.20180419-x86_64-linux/vendor/linux-x86_64"
$ ls $IMAGE_OPTIM_BIN
advpng gifsicle jhead jpegoptim jpeg-recompress jpegtran libjpeg.so libpng.so libz.so optipng pngcrush pngquant
$ $IMAGE_OPTIM_BIN/advpng
/path/to/gems/ruby-2.4.0/gems/image_optim_pack-0.5.0.20180419-x86_64-linux/vendor/linux-x86_64/advpng: /lib/libc.so.6: version `GLIBC_2.14' not found (required by /path/to/gems/ruby-2.4.0/gems/image_optim_pack-0.5.0.20180419-x86_64-linux/vendor/linux-x86_64/advpng)
/path/to/gems/ruby-2.4.0/gems/image_optim_pack-0.5.0.20180419-x86_64-linux/vendor/linux-x86_64/advpng: /lib/libc.so.6: version `GLIBC_2.14' not found (required by /path/to/gems/ruby-2.4.0/gems/image_optim_pack-0.5.0.20180419-x86_64-linux/vendor/linux-x86_64/libz.so)
I think the important part is:
version `GLIBC_2.14' not found
I checked the version of glibc installed on my system, and it is only 2.12. If you are able to upgrade glibc via your system's package manager, try that first. If you can't upgrade glibc, then just use an older version of the gems as described above.