Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heroku stack-18 issue: error while loading shared libraries: libpng12.so.0: cannot open shared object file: #15

Open
abury opened this issue Jan 23, 2019 · 13 comments

Comments

@abury
Copy link

abury commented Jan 23, 2019

Hey guys.

Thanks for the great gem! It's been really helpful so far. Unfortunately, we've run into a bit of a snag. It looks like the binary used in this gem relies on libpng12, however, this is not pre-installed on Heroku's new stack (Based on Ubtunu 18.04).

https://devcenter.heroku.com/articles/stack-packages

What is the best way to resolve this issue? Let me know if I can help out at all 👍

@nicholasklick
Copy link
Owner

Let me do some investigation. Are you currently blocked by this?

@abury
Copy link
Author

abury commented Jan 23, 2019

Hey @nicholasklick thanks for the response!.
We've been blocked for a while (I don't raise a github issue unless I'm desperate 😆), but last night I tried embedding a binary with the project's bin folder and configuring it in the IMGKit initializer and it looks like that did the trick! I had to try a few different versions (and getting a binary as opposed to a .deb file was a pain. But I eventually found https://github.com/rposborne/wkhtmltopdf-heroku and used this one (version 0.12.5)
Would be great to help other folks with this, so let me know if I can provide any more insight.

@josh-works
Copy link

josh-works commented Apr 24, 2019

I'll add some quick notes on this - our team uses Codeship, and the tests we have that rely on wkhtmltoimage have started failing. Of course, it runs fine locally, but when ssh'd into Codeship's build to debug, we get a collection of errors, printed below for your edification:

IMGKit::CommandFailedError: Command failed: /home/rof/cache/bundler/bin/wkhtmltoimage --height 400 --quality 75 --width 400 --crop-h 400 --zoom 0.7 --format jpg - -: /home/rof/cache/bundler/gems/wkhtmltoimage-binary-0.12.5/libexec/wkhtmltoimage-amd64: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory

    /home/rof/cache/bundler/gems/imgkit-1.3.10/lib/imgkit/imgkit.rb:111:in `to_img'
    .
    .
    .
    rest of stack trace

When on the box:

$ gem install wkhtmltoimage-binary
Fetching wkhtmltoimage-binary-0.12.5.gem
Successfully installed wkhtmltoimage-binary-0.12.5
1 gem installed
$ wkhtmltoimage
/home/rof/cache/bundler/gems/wkhtmltoimage-binary-0.12.5/libexec/wkhtmltoimage-amd64: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
gem list | grep wk
wkhtmltoimage-binary (0.12.5)

I think dropping to 0.12.4 might do it. I'll try it and update here!

Update: That did it. no errors with:

# Gemfile
gem "wkhtmltoimage-binary", "0.12.4"

@nicholasklick
Copy link
Owner

I see there are updated binaries for other ubuntu versions: https://wkhtmltopdf.org/downloads.html
I will see if I can get those added. Likely I will deprecate Ubuntu trusty since that is EOL.

@MathieuDerelle
Copy link

libpng12 has been replaced with libpng16 on heroku-18
(https://devcenter.heroku.com/articles/stack-packages)

any update on this ?
has someone been able to run this on heroku-18 ?

@abury
Copy link
Author

abury commented May 1, 2020

@MathieuDerelle read the above comments, I've gotten it to work on heroku-18

@MathieuDerelle
Copy link

MathieuDerelle commented Oct 20, 2020

thanks @abury but it did not work for me

I've replaced
gem 'wkhtmltoimage-binary
by
gem 'wkhtmltopdf-heroku'

and added an initializer :

IMGKit.configure do |config|
  config.wkhtmltoimage = Gem.bin_path('wkhtmltopdf-heroku', 'wkhtmltopdf-linux-amd64')
end

the error went away but the images exported from HTML were always trash : 15 bytes
0A0A0A0A 0A0A0A0A 0A0A0A0A 0A0A0A

@MathieuDerelle
Copy link

removing this gem and using the buildpack https://github.com/chap/wkhtmltopdf-heroku-18-buildpack worked for me

@lanke96
Copy link

lanke96 commented Dec 16, 2020

removing this gem and using the buildpack https://github.com/chap/wkhtmltopdf-heroku-18-buildpack worked for me

I spent hours on this. I tried using the buildpack, but never crossed my mind removing the gems. Thanks!

@rafaelp
Copy link

rafaelp commented Jan 6, 2021

You can use the build pack heroku-buildpack-dpkg and add Debfile in the root with content:
http://mirrors.kernel.org/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1_amd64.deb

It will install the missing library on the server on deploy

@Adilmar
Copy link

Adilmar commented Feb 17, 2021

Hello guys I'm having the following error using heroku tesseract, does anyone know how to solve I'm using stack 20

pytesseract.pytesseract.TesseractError: (127, 'tesseract: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory')

@abhaysarkar
Copy link

2024-10-21T11:24:19.765828+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pytesseract/pytesseract.py", line 489, in
2024-10-21T11:24:19.765828+00:00 app[web.1]: Output.STRING: lambda: run_and_get_output(*args),
2024-10-21T11:24:19.765828+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-21T11:24:19.765829+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pytesseract/pytesseract.py", line 352, in run_and_get_output
2024-10-21T11:24:19.765829+00:00 app[web.1]: run_tesseract(**kwargs)
2024-10-21T11:24:19.765829+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pytesseract/pytesseract.py", line 284, in run_tesseract
2024-10-21T11:24:19.765830+00:00 app[web.1]: raise TesseractError(proc.returncode, get_errors(error_string))
2024-10-21T11:24:19.765832+00:00 app[web.1]: pytesseract.pytesseract.TesseractError: (-11, "tesseract: /app/vendor/tesseract-ocr/lib/libtiff.so.5: no version information available (required by /app/vendor/tesseract-ocr/lib/liblept.so.5) read_params_file: Can't open txt Tesseract Open Source OCR Engine v4.0.0-rc1-11-gb15fb with Leptonica Warning: Invalid resolution 0 dpi. Using 70 instead. Estimating resolution as 263 contains_unichar_id(unichar_id):Error:Assert failed:in file ../../src/ccutil/unicharset.h, line 509")
2024-10-21T11:24:19.766497+00:00 app[web.1]: 10.1.50.82 - - [21/Oct/2024:11:24:19 +0000] "POST /api/process_image/ HTTP/1.1" 500 134658 "-" "PostmanRuntime/7.42.0"
2024-10-21T11:24:19.767874+00:00 heroku[router]: at=info method=POST path="/api/process_image/" host=boxcutting-app-233e1daeaeab.herokuapp.com request_id=4f5194a3-d1dd-4816-9b5d-e9b01fdad089 fwd="122.161.160.242" dyno=web.1 connect=1ms service=9500ms status=500 bytes=134983 protocol=https

@abhaysarkar
Copy link

2024-10-21T11:32:51.485901+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pytesseract/pytesseract.py", line 489, in
2024-10-21T11:32:51.485901+00:00 app[web.1]: Output.STRING: lambda: run_and_get_output(*args),
2024-10-21T11:32:51.485901+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^
2024-10-21T11:32:51.485902+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pytesseract/pytesseract.py", line 352, in run_and_get_output
2024-10-21T11:32:51.485902+00:00 app[web.1]: run_tesseract(**kwargs)
2024-10-21T11:32:51.485902+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pytesseract/pytesseract.py", line 284, in run_tesseract
2024-10-21T11:32:51.485902+00:00 app[web.1]: raise TesseractError(proc.returncode, get_errors(error_string))
2024-10-21T11:32:51.485903+00:00 app[web.1]: pytesseract.pytesseract.TesseractError: (-11, "tesseract: /app/vendor/tesseract-ocr/lib/libtiff.so.5: no version information available (required by /app/vendor/tesseract-ocr/lib/liblept.so.5) read_params_file: Can't open txt Tesseract Open Source OCR Engine v4.0.0-rc1-11-gb15fb with Leptonica Warning: Invalid resolution 0 dpi. Using 70 instead. Estimating resolution as 263 contains_unichar_id(unichar_id):Error:Assert failed:in file ../../src/ccutil/unicharset.h, line 509")
2024-10-21T11:32:51.486376+00:00 app[web.1]: 10.1.47.184 - - [21/Oct/2024:11:32:51 +0000] "POST /api/process_image/ HTTP/1.1" 500 134660 "-" "PostmanRuntime/7.42.0"
2024-10-21T11:32:51.488615+00:00 heroku[router]: at=info method=POST path="/api/process_image/" host=boxcutting-app-233e1daeaeab.herokuapp.com request_id=e73b2ced-75cb-46db-9a88-dbbfb2a6c79c fwd="122.161.160.242" dyno=web.1 connect=1ms service=2187ms status=500 bytes=134985 protocol=https

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

No branches or pull requests

8 participants