解决libXtst.so 缺失问题

在使用github actions 构建docker 镜像之后,我拉取了之前的puppeteer-screensho并运行:

docker pull redream/puppeteer-screenshot:master
docker run redream/puppeteer-screenshot:master

结果报错了:

Error: Failed to launch chrome!
/project/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libXtst.so.6: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

好端端的代码说bug 就bug 了,根据关键词libXtst.so.6查了很多,最终发现是因为在CI 流程中,缺少了一些依赖库需要安装,找到了一篇文章,给了一条命令:

sudo apt-get update && apt-get install -y libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb libgbm-dev

我加到GitHub actions里面,报了另一个错误:

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
Error: Process completed with exit code 100.

为啥没权限啊?刚开始查的文章说要加上sudo,明明加了呀,最后找到一篇文章,恍然大悟,哎呀:

sudo apt-get update && sudo apt-get upgrade

the commands before and after && are separate commands, so sudo must be used by both commands.

&& 符号后面也要sudo 啊!

Leave a Comment

邮箱地址不会被公开。 必填项已用*标注