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

前端 未结 11 1569
一向
一向 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-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

提交回复
热议问题