在生产中使用image_optim_pack丢失二进制文件错误

时间:2017-08-10 10:44:49

标签: ruby-on-rails image-optimization

我尝试使用paperclip-optimizer部署Rails应用程序,并且它给我一个关于丢失二进制文件的错误。我已经捆绑了image_optim_pack来提供二进制文件,但仍然可以得到这个:

ImageOptim::BinResolver::Error occurred
pngcrush worker: `pngcrush` not found; please provide proper binary or di=
sable this worker (--no-pngcrush argument or `:pngcrush =3D> false` throu=
gh options)
advpng worker: `advpng` not found; please provide proper binary or disabl=
e this worker (--no-advpng argument or `:advpng =3D> false` through optio=
ns)
optipng worker: `optipng` not found; please provide proper binary or disa=
ble this worker (--no-optipng argument or `:optipng =3D> false` through o=
ptions)
pngquant worker: `pngquant` not found; please provide proper binary or di=
sable this worker (--no-pngquant argument or `:pngquant =3D> false` throu=
gh options)
jhead worker: `jhead` not found, `jpegtran` not found; please provide pro=
per binary or disable this worker (--no-jhead argument or `:jhead =3D> fa=
lse` through options)
jpegoptim worker: `jpegoptim` not found; please provide proper binary or =
disable this worker (--no-jpegoptim argument or `:jpegoptim =3D> false` t=
hrough options)
jpegtran worker: `jpegtran` not found; please provide proper binary or di=
sable this worker (--no-jpegtran argument or `:jpegtran =3D> false` throu=
gh options)
gifsicle worker: `gifsicle` not found; please provide proper binary or di=
sable this worker (--no-gifsicle argument or `:gifsicle =3D> false` throu=
gh options)
  • 服务器Ubuntu 14.04.5 LTS
  • Rails 5.1.3
  • Ruby 2.4.1
  • nginx 1.9.10
  • 乘客5.0.24
  • image_optim(0.25.0)
  • image_optim_pack(0.5.0.20170803 x86_64-linux)

2 个答案:

答案 0 :(得分:1)

tl; dr,image_optim_pack中的二进制文件可能是针对一个比你试图运行它的系统更新的系统构建的。尝试查找适用于您系统的最新版本的image_optim_pack。对我来说,以下版本有效:

gem "image_optim", "~> 0.25"
gem "image_optim_pack", "= 0.2.3"

更多详情

要获取有关失败的信息,请运行:

$ bundle exec image_optim --info

我看到这样的事情:

$ 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:

它没有说明为什么工人失败了。但是你可以运行worker二进制文件来找出:

# 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)

我认为重要的部分是:

version `GLIBC_2.14' not found

我检查了系统上安装的glibc版本,它只有2.12。如果您能够通过系统的软件包管理器升级glibc,请先尝试。如果您无法升级glibc,那么只需使用旧版本的宝石,如上所述。

答案 1 :(得分:0)

image_optim_pack 版本 0.5.020170815 我遇到了同样的问题。

升级到最新版本(截至目前为 0.5.020170831 )为我解决了这个问题。