Rails:运行 wkhtmltopdf 时出错 --(加载共享库时出错)

发布于 2024-10-17 16:58:51 字数 1230 浏览 4 评论 0原文

当我的应用程序运行时(或当我从命令行运行时) wkhtmltopdf 命令时,我收到以下错误:(从命令行显示)

#> wkhtmltopdf 
wkhtmltopdf: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory

我注意到该 lib 确实位于 /usr/lib 文件夹中,但不是/lib 文件夹。它属于其中哪一个重要吗?有什么办法让它能够识别吗?

#> ls -l /usr/lib/libXrender.so*
lrwxrwxrwx 1 root root    19 Feb 17 07:20 /usr/lib/libXrender.so -> libXrender.so.1.3.0
lrwxrwxrwx 1 root root    19 Feb 17 07:20 /usr/lib/libXrender.so.1 -> libXrender.so.1.3.0
-rwxr-xr-x 1 root root 39184 Jan 29  2010 /usr/lib/libXrender.so.1.3.0

#> ls -l /lib/libXrender.so*
ls: cannot access /lib/libXrender.so*: No such file or directory

我还检查了 lib 的依赖关系,

# ldd /usr/lib/libXrender.so.1
    libX11.so.6 => /usr/lib/libX11.so.6 (0x00002b9cb5afd000)
    libc.so.6 => /lib/libc.so.6 (0x00002b9cb5e04000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0x00002b9cb6143000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00002b9cb6347000)
    libdl.so.2 => /lib/libdl.so.2 (0x00002b9cb654d000)
    /lib64/ld-linux-x86-64.so.2 (0x0000555555554000)

它在 EngineYard gentoo 服务器上运行

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

#> wkhtmltopdf 
wkhtmltopdf: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory

I noticed the lib is indeed in the /usr/lib folder but not the /lib folder. Does it matter which one of these it is in? Is there any way to get it to recognize it?

#> ls -l /usr/lib/libXrender.so*
lrwxrwxrwx 1 root root    19 Feb 17 07:20 /usr/lib/libXrender.so -> libXrender.so.1.3.0
lrwxrwxrwx 1 root root    19 Feb 17 07:20 /usr/lib/libXrender.so.1 -> libXrender.so.1.3.0
-rwxr-xr-x 1 root root 39184 Jan 29  2010 /usr/lib/libXrender.so.1.3.0

#> ls -l /lib/libXrender.so*
ls: cannot access /lib/libXrender.so*: No such file or directory

I also checked dependencies of the lib

# ldd /usr/lib/libXrender.so.1
    libX11.so.6 => /usr/lib/libX11.so.6 (0x00002b9cb5afd000)
    libc.so.6 => /lib/libc.so.6 (0x00002b9cb5e04000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0x00002b9cb6143000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00002b9cb6347000)
    libdl.so.2 => /lib/libdl.so.2 (0x00002b9cb654d000)
    /lib64/ld-linux-x86-64.so.2 (0x0000555555554000)

This is running on an EngineYard gentoo server

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

再见回来 2024-10-24 16:58:51

Unix 软件包 x11-libs/libXext 和 x11-libs/libXrender 是依赖项

Gentoo:

sudo emerge libXext libXrender

PDFkit wiki 还更详细地解释了如何让 wkhtmltopdf 在引擎码上工作。
PDFkit wiki

Debian 或 Ubuntu:

sudo apt-get install libxrender1

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
谈场末日恋爱 2024-10-24 16:58:51

我在 Debian Squeeze、amd64 上也遇到了同样的问题。安装 libxrender1 为我解决了这个问题。

sudo apt-get install libxrender1

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

sudo apt-get install libxrender1
绝影如岚 2024-10-24 16:58:51

之后我还需要做:

sudo apt-get install libfontconfig1

I need also do after:

sudo apt-get install libfontconfig1
谜兔 2024-10-24 16:58:51

今天在运行 静态版本 wkhtmltopdf 的 RHEL7 计算机上遇到了这个问题。解决方案是安装一些依赖项:

yum install libXrender libXext fontconfig 

Ran into this today on a RHEL7 machine running the static version of wkhtmltopdf. Solution was to install a few dependencies:

yum install libXrender libXext fontconfig 
ゃ人海孤独症 2024-10-24 16:58:51

对于 Ubuntu 16(来自全新的 Docker 安装):

apt install -y libxrender1 libxext6

With Ubuntu 16 (from a fresh Docker install):

apt install -y libxrender1 libxext6
剑心龙吟 2024-10-24 16:58:51

如果您的系统是 64 位,并且您的软件需要 32 位库,则需要添加标志“i386”,

例如在 ubuntu 上:

sudo apt-get install libxrender1:i386

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
梦里寻她 2024-10-24 16:58:51

我遇到了完全相同的问题!对我来说,解决方案是安装 64 位版本的 wkhtmltoimage。

I was having the exact same problem! The solution, to me, was to install the 64bit version of wkhtmltoimage.

倾城泪 2024-10-24 16:58:51

我在重建我的一个容器后遇到了这个问题,而在此之前一切都工作正常。我在网上找到的所有答案都不适合我,所以以下是我的故障排除和解决方法:

1。检查所有依赖项是否都存在:

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

这是我从中得到的结果

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)

“未找到”意味着依赖项丢失

2. apt更新并安装

更新你的apt,因为它很可能找不到安装所需的库

apt-get update

现在我安装了缺少的依赖项,其中“未找到”以上结果。请注意,对于 libxrenderlibxext 我必须安装 libxrender-devlibxext-dev

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

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

水晶透心 2024-10-24 16:58:51

我在 Ubuntu 18.04 生产服务器上运行 Rails 5.2 应用程序时遇到了同样的问题,问题是服务器上缺少 libXrender 的依赖项

这是我解决它的方法

运行以下命令来搜索缺少的依赖项:

sudo apt-cache search libXrender

这将显示以下输出:

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

如果您在生产服务器上运行,只需仅安装 libxrender1 (用于渲染 PDF):

sudo apt-get install libxrender1

另外,如果可能的话在您的服务器上运行过时库的升级:

sudo apt upgrade

完成所有这些后,只需重新启动您的应用程序服务器(如果您的应用程序服务器是 puma 并且您为该服务器设置了 systemd):

sudo systemctl restart puma

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
回眸一遍 2024-10-24 16:58:51
sudo apt-get install xvfb

安装依赖包。

更新节点模块 wkhtmltopdf index.js

wkhtmltopdf.command = 'wkhtmltopdf'; to 'wkhtmltopdf.command =
'xvfb-run wkhtmltopdf';'
sudo apt-get install xvfb

to install the dependency package.

Update the node-modules wkhtmltopdf index.js

wkhtmltopdf.command = 'wkhtmltopdf'; to 'wkhtmltopdf.command =
'xvfb-run wkhtmltopdf';'
戏剧牡丹亭 2024-10-24 16:58:51

在 Amazon Linux 上对我有用的东西(用于未来的谷歌搜索) 2018:03

yum localinstall -y https://repo.almalinux.org/almalinux/8/AppStream/x86_64/os/Packages/libpng15-1.5.30-7.el8.x86_64.rpm
yum localinstall -y https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm

What worked for me (for future google searchs), on an Amazon Linux 2018:03

yum localinstall -y https://repo.almalinux.org/almalinux/8/AppStream/x86_64/os/Packages/libpng15-1.5.30-7.el8.x86_64.rpm
yum localinstall -y https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm
一页 2024-10-24 16:58:51

请注意,wkhtmltopdf 有一个以 UPX 压缩格式分发的可执行版本,ldd 和 file 都会报告该文件是静态链接的,即使有效负载需要共享库。

要检查尝试,

strings <executable> | fgrep UPX

如果您看到任何“UPX”id 字符串,请安装 upx 并在文件副本上使用“upx -d”(因为 upx 可以正常工作),然后在未压缩的文件上运行 ldd。

Note that there is an executable version of wkhtmltopdf distributed in a UPX compressed format, ldd and file will both report that this file is statically linked even though the payload requires shared libraries.

To check try

strings <executable> | fgrep UPX

If you see any "UPX" id strings then install upx and use "upx -d" on a copy of the file (as upx works in place) and then run ldd on the uncompressed file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文