Rails: Error running wkhtmltopdf — (error while loading shared libraries)

前端 未结 11 1567
一向
一向 2021-02-04 23:12

When my app runs (or when I run from commandline) the wkhtmltopdf command I get the following error: (showing it from command line)

#> wkhtmltopdf 
wkhtmltopd         


        
相关标签:
11条回答
  • 2021-02-04 23:55

    The Unix packages x11-libs/libXext and x11-libs/libXrender are dependencies

    Gentoo:

    sudo emerge libXext libXrender
    

    PDFkit wiki also explains in more detail how to get wkhtmltopdf working on engine yard. PDFkit wiki

    Debian or Ubuntu:

    sudo apt-get install libxrender1
    

    Hope this helps

    0 讨论(0)
  • 2021-02-04 23:59

    I had this same issue on running a Rails 5.2 application on an Ubuntu 18.04 production server, the issue was that there were missing dependencies for libXrender on the server

    Here's how I solved it:

    Run the command below to search for the missing dependencies:

    sudo apt-cache search libXrender
    

    This will display the output below:

    libxrender-dev - X Rendering Extension client library (development files)
    libxrender1 - X Rendering Extension client library
    libreoffice - office productivity suite (metapackage)
    

    If you're running on a production server, simply install libxrender1 only (for rendering PDFs):

    sudo apt-get install libxrender1
    

    Also, if possible run upgrades for outdated libraries on your server:

    sudo apt upgrade
    

    Once, all these have been completed, simply restart your application server (If your application server is puma and if your setup systemd for the server):

    sudo systemctl restart puma
    

    That's all.

    I hope this helps

    0 讨论(0)
  • 2021-02-05 00:00

    I had the same, issue on Debian Squeeze, amd64. Installing libxrender1 solved the issue for me.

    sudo apt-get install libxrender1
    
    0 讨论(0)
  • 2021-02-05 00:01

    I had this issue after rebuilding one of my containers, while before everything was working fine. All the answers I found online didn't work for me, so here's how I troubleshooted and resolved:

    1. Check if all dependencies are there:

    ldd path/to/your/binary/file/wkhtmltopdf-amd64

    Here's what I got from that

    linux-vdso.so.1 =>  (0x00007ffded169000)
    libXrender.so.1 => not found
    libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f117bab0000)
    libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f117b806000)
    libXext.so.6 => not found
    libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f117b4cc000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f117b2b2000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f117b0ae000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f117aea6000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f117ac89000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f117a907000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f117a5fe000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f117a3e8000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f117a01e000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f117bcf3000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f1179df5000)
    libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f1179bd0000)
    libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f11799ae000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f11797aa000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f11795a4000)
    

    Where I got "not found" means the dependencies were missing

    2. apt update and install

    Update your apt, as it's likely it won't find the libraries needed to install

    apt-get update

    Now I installed the missing dependencies that had the "not found" in the results above. Take note that for the libxrender and libxext I had to install libxrender-dev and libxext-dev.

    apt-get install -y libxrender-dev libxext-dev

    0 讨论(0)
  • 2021-02-05 00:09

    If your system is 64 bits, and your software requires 32 bits libs, you need to add the flag "i386",

    for example on ubuntu:

    sudo apt-get install libxrender1:i386
    
    0 讨论(0)
提交回复
热议问题