Using Puppeteer: libnss3 no file or directory issue on Gitpod

I’m using puppeteer with nodejs and I’m getting this error ‘libnss3.so’ so such file or directory . I used homebrew to install this library and I can see the file is located in home/linuxbrew/.linuxbrew but even after installation, it cannot find the libnss3 file and I get the same error.

I googled it but it’s an issue with puppeteer on Linux based systems but I don’t know how to get this working on Gitpod since sudo is not allowed . And homebrew should’ve solved it but nope.

I tried all options I could find. Created docker file to install the libnss3 library but still it says no such file. I’m at my wit’s end here.

Please help.

2 Likes

Hi @JohnYep,

Sorry about this issue. Indeed brew install libnss3-dev or sudo apt-get install libnss3-dev (in a Dockerfile) should have solved this.

Could you please share a link to your project where this error happens? Along with precise steps as to how the error can be reproduced? That way we’ll be able to reproduce the failure, and try to find a way to solve it (and then even send you a PR to fix it).

Thank you for the response. This error is holding back my project and its been days looking up for fix. I’m new here and really appreciate any help with this. Regading my post that was flagged , i apologise for it. It wont happen again.

Simply, running the node server using : node server.js will reproduce the error.

I’m sharing the snapshot:

1 Like

@JohnYep Many thanks for providing a snapshot & the steps. I can indeed reproduce this error:

$ node server.js
port running 
(node:1943) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
/workspace/gitpodPuppeteerTest/node_modules/puppeteer/.local-chromium/linux-782078/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

However, I also notice a few problems:

  • Both .gitpod.yml and .gitpod.Dockerfile are new files that were not committed or pushed to a repo. To get a .gitpod.yml and .gitpod.Dockerfile config to take effect, you need to add + commit + push both files to your repository, and then create a new Gitpod workspace for that repository.

  • The .gitpod.Dockerfile has a typo: it says sido instead of sudo.

I’ll try to fix the config and push to a repo in order to find a solution for you.

Sorry about that. My actual project was quite big and not necessary to reproduce the error. so, i quickly made a new repo and brought it to gitpod and then created the those files in the workspace itself.

sorry for the ‘sido’ typo but if you correct it , it would still wont work.

would you lik me to share the link again with the appropriate files included in the repo?

1 Like

@JohnYep Makes sense, many thanks for building a minimal reproduction repo.

I’ve added and committed all the files into my fork: https://github.com/jankeromnes/gitpodPuppeteerTest and I’ll be iterating on that to see if I can solve the error.

1 Like

Update: Ok, now it fails with:

(node:1678) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
/workspace/gitpodPuppeteerTest/node_modules/puppeteer/.local-chromium/linux-782078/chrome-linux/chrome: error while loading shared libraries: libXrandr.so.2: cannot open shared object file: No such file or directory

So I conclude that sudo apt-get install -y libnss3-dev worked as intended, and that we just need to install a few more dependencies.

I’ll do that now.

1 Like

Can you try this command:
sudo apt-get install libnspr4 libnss3 libnss3-nssdb libnss3-tools

@JohnYep Thanks! I actually went and installed the entire official list of Puppeteer dependencies for Ubuntu:

Aha! There we go:

port running 
(node:1711) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
[0903/170831.815827:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

This one I’m familiar with.

Actually I’ve already configured Gitpod for Puppeteer previously while automating the dev setup of https://github.com/Schachte/Mermrender (sorry, I should have remembered about that earlier…)

But the main thing is to tell Puppeteer to tell Chromium not to use the sandbox, because it doesn’t work in Docker containers (and is actually not needed to safely run tests in a personal dev container).

1 Like

@JohnYep Update: With the latest changes in https://github.com/jankeromnes/gitpodPuppeteerTest the Puppeteer server now starts without issues:

$ node server.js 
port running

:tada:

1 Like

Thank You

It’s working now. This means a lot. Thank you for taking the time to fix it. Cheers :beer:

1 Like

Hey thanks for posting this JohnyYep.

I haven’t gotten around to testing puppeteer yet on here.

2 Likes

thanks a lot @jan , I could finally run set of tests on gitpod:

  • the visual tests
  • e2e tests

for the repo:

1 Like