Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

pngquant: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory #93

Closed
forgo opened this issue Apr 18, 2017 · 16 comments

Comments

@forgo
Copy link

forgo commented Apr 18, 2017

"image-webpack-loader": "^3.3.0"

I have a build process running on a remote machine via Jenkins. I am using NPM and triggering a build with the following command:

> npm install && npm test && NODE_ENV=production webpack --config webpack.production.config.js

My webpack.production.config.js section for image-webpack-loader looks like this:

loader: 'image-webpack-loader',
                    options : {
                        query: {
                            mozjpeg: {
                                progressive: true
                            },
                            optipng: {
                                optimizationLevel: 7
                            },
                            gifsicle: {
                                interlaced: false
                            }
                        }
                    }

For every png file webpack is trying to load, I get messages that end with:

.../node_modules/pngquant-bin/vendor/pngquant: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory

If I manually go into this directory and execute ./pngquant, I can indeed see that it cannot find that shared object file.

Strangely enough, on this red hat machine I am building on, this shared object is definitely available. See the output of the locate command below:

$ locate libpng12.so.0
/usr/lib/libpng12.so.0
/usr/lib/libpng12.so.0.50.0

So what's the problem here?

I have seen many references claiming that following should solve this problem:

  • npm install image-webpack pngquant (did not work)
  • brew install libpng
  • sudo apt-get install libpng-dev
  • ... and so on

I had the ability to run the brew command on my local development machine -- which I believe gave me a temporary workaround for developing.

Unfortunately, I do not have admin privileges on my build machine, and these fixes ultimately do not get to the root of the issue.

Installing a system-wide binary should not be necessary via an package dependency manager like NPM, so I'm really trying to get at the root of the issue here and wondering if anybody has an ideas.

I even tried reverting to an older image-webpack-loader version (2.0.0 from 3.3.0) because I saw someone mention that this issue did not occur for 2.x.x. Nevertheless, this did not change my outcome.

@tcoopman
Copy link
Owner

I think you already saw #51. As I said there this is an issue with a dependency of this loader, so please report it over there.

Thanks

@kopax
Copy link

kopax commented Jun 5, 2017

Can we reopen this ? I am hitting the same issue on alpine. This seriously increase our images sizes. I think you shouldn't use a library that ship deprecated binaries on their repo.

@tcoopman
Copy link
Owner

tcoopman commented Jun 5, 2017

@kopax how do you propose this issue?

@kopax
Copy link

kopax commented Jun 6, 2017

I would say to use to use the libpng available on the linux host. By default they have an up to date version or it can be installed. There is no reason to ship the lib and there are chances that it won't work on other distros.

@tcoopman
Copy link
Owner

tcoopman commented Jun 6, 2017

@kopax that's something what a dependency of this loader could do. This package is not much more than a wrapper for imagemin packages. So this is not something we should solve.

@kopax
Copy link

kopax commented Jun 7, 2017

@tcoopman is there an option that would allow the use of it on alpine linux ? I think this need to be solve at some point...

How about creating symlinks of host binaries upon install ?

@tcoopman
Copy link
Owner

tcoopman commented Jun 7, 2017

It should certainly be possible. But I think you are better of looking for a solution at the correct dependency repo. Maybe you can find a solution over there. If you find a solution, feel free to link it here or create a PR for the readme

@kopax
Copy link

kopax commented Jun 9, 2017

@tcoopman do you have the repo url ? thanks!

@iamcaleberic
Copy link

wget http://sourceforge.net/projects/libpng/files/libpng16/1.6.32/libpng-1.6.32.tar.gz/download -O libpng.tar.gz && tar -xvf libpng.tar.gz && cd libpng-1.6.32 && bash configure --prefix=/usr --disable-static && make install

If you having this issue on linux this will solve it for you...if you need sudo permissions add them

@wenisy
Copy link

wenisy commented Oct 9, 2017

#93 (comment)
@iamcaleberic Thanks for your workaround, but after I tried there is still same issue with me.

I tried it on CentOS 7, I think it should be same, did I miss something?

@iamcaleberic
Copy link

iamcaleberic commented Oct 10, 2017

@wenisy I checked and libpng version 1.5.13-7 is available on Cent OS packages.
Do try
# yum install libpng / # yum install libpng12
or
# dnf install libpng / # dnf install libpng12

Also check this thread for more on that
https://centos.org/forums/viewtopic.php?t=62750&p=264544

Tell me how that goes.

@wenisy
Copy link

wenisy commented Oct 25, 2017

@iamcaleberic I gave you a thumb up, hope you got the notification.
Thanks again, you really solved my problem!

@campaignupgrade
Copy link

None of the above fixes worked for me, but this one does:

echo "deb http://mirrors.kernel.org/ubuntu/ xenial main" | sudo tee -a /etc/apt/sources.list && sudo apt-get update && sudo apt install -y --allow-unauthenticated libpng12-0

@igorcaldeira
Copy link

Thanks @slamorte , helped me

@imjayson
Copy link

Thanks @slamorte. Had to use sudo apt update instead of sudo apt-get update https://stackoverflow.com/questions/50942353/e-repository-http-dl-google-com-linux-chrome-remote-desktop-deb-stable-relea/50942354

The following worked for me:
echo "deb http://mirrors.kernel.org/ubuntu/ xenial main" | sudo tee -a /etc/apt/sources.list && sudo apt update && sudo apt install -y --allow-unauthenticated libpng12-0

@jordanmiguel
Copy link

@iamcaleberic this worked for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants