So one day, out of the blue, my grunt build job started failing in jenkins. I was quite confused why. Because it was working fine if I did it from my dev machine. I have a PC, a personal laptop, a work laptop, and two home servers (which are just old laptops converted to do various stuffs), and it worked fine in all, except in one of the home server which is running jenkins. Everytime I did grunt build there, I got:

Running "imagemin:dist" (imagemin) task
Warning: Error: Command failed: /var/lib/jenkins/jobs/GRII-Eropa-Build/workspace/frontend/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin/vendor/optipng: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /var/lib/jenkins/jobs/GRII-Eropa-Build/workspace/frontend/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin/vendor/optipng)
 in file app/assets/img/bg-black.png Use --force to continue.

Aborted due to warnings. It was a little confusing at first, because I am the type who do “sudo apt-get update && sudo apt-get dist-upgrade” regularly. So if the library suddenly doesn’t work with some newer lib version, it should fail also on my dev machine. My dev machines are using Debian Jessie as well and it means newer lib, so it should have failed on my dev machine first. I tried a few approach trying to solve the GLIBC_2.14 problem, but it was not very fruitful, and it started to get a little bit annoying.

I tried a different approach after that. I set the build job to always clean my node_modules folder before running the build again in the hope it was just something with the npm packages, but I got the same result. Then I tried logging in as jenkins, going to the workspace folder, and deleted the single grunt-contrib-imagemin folder, and tried to do “npm install grunt-contrib-imagemin” manually. It was only at that time I see the actual problem:

> pngquant-bin@1.0.1 postinstall /var/lib/jenkins/jobs/GRII-Eropa-Build/workspace/frontend/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/    imagemin-pngquant/node_modules/pngquant-bin
> node lib/install.js

  downloading : https://raw.github.com/imagemin/pngquant-bin/v1.0.1/vendor/linux/x64/pngquant
     progress : [====================] 100% 0.0s


⚠ pre-build test failed, compiling from source...
✖ pngquant failed to build, make sure that libpng-dev is installed

{ [Error: Command failed: make: *** No rule to make target `config.mk', needed by `lib/libimagequant.a'.  Stop.
] killed: false, code: 2, signal: null }

> gifsicle@1.0.3 postinstall /var/lib/jenkins/jobs/GRII-Eropa-Build/workspace/frontend/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/    imagemin-gifsicle/node_modules/gifsicle
> node lib/install.js

  downloading : https://raw.github.com/imagemin/gifsicle-bin/v1.0.3/vendor/linux/x64/gifsicle
     progress : [====================] 100% 0.0s


✔︎ pre-build test passed successfully!

> jpegtran-bin@1.0.2 postinstall /var/lib/jenkins/jobs/GRII-Eropa-Build/workspace/frontend/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/    imagemin-jpegtran/node_modules/jpegtran-bin
> node lib/install.js

  downloading : https://raw.github.com/imagemin/jpegtran-bin/v1.0.2/vendor/linux/x64/jpegtran
     progress : [====================] 100% 0.0s


✔︎ pre-build test passed successfully!

> optipng-bin@1.0.1 postinstall /var/lib/jenkins/jobs/GRII-Eropa-Build/workspace/frontend/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/    imagemin-optipng/node_modules/optipng-bin
> node lib/install.js

  downloading : https://raw.github.com/imagemin/optipng-bin/v1.0.1/vendor/linux/x64/optipng
     progress : [====================] 100% 0.0s


⚠ pre-build test failed, compiling from source...
✖ { [Error: Command failed: ] killed: false, code: 1, signal: null }

Aha! It was missing the libpng-dev package for some reason.

So after this simple apt-get command to install the package:

sudo apt-get install libpng-dev

I cleaned the folder and did npm install again. This time, imagemin installed successfully, and the grunt build also succeeded. I hope this can help you if you have the same problem.

For CentOS user, I think the package is called libpng-devel.