Unable to use libpng dependency

Hi all,
As far as I am aware, both Ubuntu Xenial (18) and Focal (20) come with libpng (which one of the executables I use to build my site uses). However, this executable fails with

 error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory

Now I could try to use apt-get to install these dependencies however as far as I’m aware this would be impossible on Netlify as no sudo permissions are available on the build images. Is there some other solution to this problem?


Hiya @seagullpat!

I’d recommend building a static version of your dependency that does not require the shared lib. We try to keep our default build image really small, and adding a bunch of shared libraries that are only needed by a few folks is something we try to avoid, since it will slow things down for everyone else as we have to transfer the build image around before building.

We are using at newest Xenial during build (could still be using Trusty, if you configured your site >2 years ago, here), so definitely don’t try bringing binaries from ubuntu 20 as that would be very unlikely to work before we upgrade again, which we are not planning to do very soon.

You are correct that you won’t be able to install things using apt, good intuition! My normal advice is to do what you’re doing: bring a binary built for the OS in question (which in most cases will be Xenial with an x86_64 architecture). Just make sure it doesn’t rely on optional libs (we have libc and some others, but png is not required for most other tools,. so may not be there)

Hey, I have the same issue, i.e. libpng, are there any tutorials to accomplish what you’re describing? I am not entirely sure how to “bring in a binary built for Xenial”. Bring it in how, where etc?


fortunately, things have gotten easier in the meantime! We now have beta homebrew support in the build image, so you might be able to get away with a build command of:

brew install libpng && do-your-normal-build

That seemed to me to install a moderately recent libpng with its development headers, which should be enough for you to use via your code.

rather than following some guidelines such as these which describe what I mentioned: Linux Basics: Static Libraries vs. Dynamic Libraries | by Erika Caoili | The Startup | Medium

1 Like

Thanks! that’s useful to know for future reference, unfortunately it didn’t seem to fix the underlying issue, which others have now posted about (Deploy failed, exit code 1: CI= jekyll build, Build script returned non-zero exit code: 2 - #4 by inakijv)

I tried brew install vips && which should work, but it tried to compile about half an OS from source and ran over the time limit. I’ll try to figure out a reduced set of packages and try again.

Hey there, @rbuchberger. This thread has been a bit quiet for the past few days. Did trying this with a reduced set of packages work? Are you still encountering issues?

Hello, sorry to leave this issue unattended! There were several similar issues raised across a few platforms, and I missed it.

Backstory missing: I maintain Jekyll Picture Tag, which is a plugin that automates responsive images. I recently changed the image processing backend from imagemagick to libvips, which is what was breaking everyone’s builds.

The issue was caused by the older version of libvips in your build image accepting slightly different arguments for PNG files. I managed to fix it with an update to the gem, no homebrew commands required. Can’t do jp2 or avif, but jpg, png, and webp work fine.

For anyone who has this issue, updating to jekyll_picture_tag 2.0.2 or later will fix it.

Thanks for your support, you all have been awesome! Sorry that my plugin caused a bunch of support threads for y’all to deal with.

1 Like

Thank you so much for sharing these details and for your kind words! I am so glad you found a solution :netliconfetti: