puppeteer / puppeteer

JavaScript API for Chrome and Firefox
https://pptr.dev
Apache License 2.0
88.41k stars 9.07k forks source link

[Bug]: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory #9386

Closed mgamini closed 1 year ago

mgamini commented 1 year ago

Bug description

Hello -

I'm trying to run puppeteer in Google Cloud Functions, and getting the following error: /workspace/.cache/puppeteer/chrome/linux-1069273/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

I have set .puppeteerrc.cjs to the example value here - without this, the Chromium binary is not found.

Any help would be greatly appreciated. Thank you!

Puppeteer version

19.4.0

Node.js version

18

npm version

9.2.0

What operating system are you seeing the problem on?

Linux

Configuration file

No response

Relevant log output

/workspace/.cache/puppeteer/chrome/linux-1069273/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory9
OrKoN commented 1 year ago

Hey, it means that dependencies that Chromium requires are missing the environment. See https://pptr.dev/troubleshooting/#running-puppeteer-in-the-cloud for potential solutions.

mgamini commented 1 year ago

Hey, it means that dependencies that Chromium requires are missing the environment. See https://pptr.dev/troubleshooting/#running-puppeteer-in-the-cloud for potential solutions.

Thank you for the response! I've previously run through that page a few times. For Google Cloud Functions, it mentions that all of the puppeteer packages are included in the nodejs10 runtime. Unfortunately, GCF no longer supports node 10, and running with the current node runtime does not work.

OrKoN commented 1 year ago

@mgamini unfortunately, we have no control over the Google Could Functions environment. You could try using Google Cloud Run which allows providing a Dockerfile with all dependencies.

jacobg commented 1 year ago

I also had this error when trying to upgrade to GCF Node 18 runtime. The Node 16 runtime works fine.

Here is the Google issue tracking this problem: https://issuetracker.google.com/266279679

CM96 commented 1 year ago

Has this been resolved yet ? I keep running into this issue on GitHub Actions.

jpreynat commented 1 year ago

It hasn't been resolved at all. I've re-opened a new issue as a Bug instead of a Feature Request this time, as it's been months and nothing has been done yet.

Upvotes are welcome: https://issuetracker.google.com/issues/278096732

OrKoN commented 1 year ago

I believe here is the full list of deps that are needed for Chromium/Chrome binaries https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/debian/dist_package_versions.json

CM96 commented 1 year ago

I believe here is the full list of deps that are needed for Chromium/Chrome binaries https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/debian/dist_package_versions.json

Hi @OrKoN the problem is that the package is supposed to come with its own dependencies. I find that counter productive to always download the missing dependencies before running puppeteer. Is there another way to solve the issue or go around it ? Your help is much appreciated.

OrKoN commented 1 year ago

@CM96 Puppeteer has no means to install system dependencies to your host. So there is no another way. You can build your own browser binaries from source but that is arguably worse than installing dependencies for existing binaries.

CM96 commented 1 year ago

@CM96 Puppeteer has no means to install system dependencies to your host. So there is no another way. You can build your own browser binaries from source but that is arguably worse than installing dependencies for existing binaries.

Okay, thanks for your clarification. I just can't wrap my head around why he was working before w/o downloading the dependencies on my GHA runner.

sidvishnoi commented 1 year ago

FYI, the upstream Google Cloud Functions issue has been resolved: https://issuetracker.google.com/issues/266279679#comment41

yesari1 commented 1 year ago

None of the above solutions worked. I am trying to deploy to google cloud run but puppeteer is not working properly. Getting the same error "libnss3.so: cannot open shared object ...". Is there any solution about that?

propedia-org commented 1 year ago

The largest free portal, fast and user-friendly interface, unlimited data source. Zamona last and actual news, music, movies, videos, products, vacancies, photos, questions and answers https://zamona.net/en/

MathiasRanna commented 12 months ago

Having the same issue. But running on aws lambda node js 18. This works when running on node 14, but I would like to run it on node 18.

yesari1 commented 12 months ago

I started to using AWS for puppeteer. And now it is working perfect. Aws has some special environment for puppeteer so you don't need to install all puppeteer environment to cloud. There is one npm package for aws, name with "chrome-aws-lambda" i guess. There are some videos that explain how to install AWS puppeteer.

@MathiasRanna And i guess Node js version must be 14 to work with puppeteer in AWS.

So anyone who encounters this problem can use AWS.

image

lucasrennok commented 12 months ago

@1yes1 I am at the same context as you: using AWS and puppeter (chrome-aws-lambda), but I'm also facing this error with libraries recently. I changed Node 12 to Node 14 and puppeter is no more working. Maybe I have to change the packages versions too, but I don't know the correct ones.

I use: "puppeteer": "^9.1.1", "puppeteer-core": "^2.1.1", "chrome-aws-lambda": "^2.0.2", "aws-lambda": "^1.0.4",

Can you tell me if you are using these packages in these versions? It would be a big help from you. Thanks.

yesari1 commented 12 months ago

@lucasrennok I am using this versions but not sure if it is working:

"chrome-aws-lambda": "^10.1.0",
"puppeteer": "^21.3.8",
"puppeteer-core": "^10.4.0",

I haven't checked this in a long time. Maybe you can try.