"Error while loading shared libraries: libnss3.so" while running Gtlab CI job to perform automated testing using webdriverio
Asked Answered
B

4

66

I'm setting up the CI job for automated testing in selenium inside Gitlab CI, but the test is failing due to the issue.

019-09-27T11:03:17.404Z INFO @wdio/cli:Launcher: Run onPrepare hook /builds/shauryav/test-react-ci-cd/node_modules/chromedriver/lib/chromedriver/chromedriver: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

I have tried numbers of solutions like installing package "@wdio/cli": "^5.13.2", "webdriverio": "^5.13.2" but nothing works. For the note, I'm not using any docker setup

/builds/shauryav/test-react-ci-cd/node_modules/chromedriver/lib/chromedriver/chromedriver: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
2019-09-27T11:03:27.415Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: timeout
    at Timeout.timeoutFunc (/builds/shauryav/test-react-ci-cd/node_modules/tcp-port-used/index.js:204:25)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)```
Belamy answered 27/9, 2019 at 12:42 Comment(3)
libnss3.so: No such file or directory → Install libnss (Debian, Ubuntu) / nss (Fedora, CentOS).Tremble
@KnudLarsen Unable to locate package libnss on ubuntu:16.04Ulberto
16.04 : libnss3 .... apt-cache search libnss and apt-file search libnss3.so .... or use the on-line search packages.ubuntu.com/search?keywords=libnss&searchon=names ... to decide package name.Tremble
E
93

try these command

apt install libnss

apt install libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev

if the above commands didn't work then go for the below one

sudo apt install libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev

Exceed answered 2/12, 2020 at 11:39 Comment(7)
Good call. On WSL, need to run apt update first or it won't find the libs.Stillmann
Note that it's 2021 and this step worked for me in installing puppeteer.js in Ubuntu 20Shill
This worked for me too on Ubuntu (WSL2) though I didn’t need any of the -dev versions (those would be required for building chromium, not simply running it).Subjunction
Installing libnss3 on Debian Buster was enough for me to get the file libnss3.so.Mccrory
Hi! I have the same problem with libnss3.so. BUT! I got it while running wdio automated tests inside of Docker container. I cannot run update, install or any other command that makes changes to container (don't have rights to modify the container). How can I make Chrome running? Any advice will be much appreciated!Solly
On Open suse, the package is mozilla-nssFrothy
This helped solve the issue on a Chromebook.Din
S
20

When you see this kind of thing, it means your OS is missing low-level libraries that are expected.

To resolve this (Debian/Ubuntu example),

  1. Make sure your package index is up-to-date.
sudo apt update -y
  1. Search the package manager's packages for the one that is missing
apt search libnss3
  1. Determine a suitable candidate from the search results
Sorting... Done
Full Text Search... Done
libnss3/oldstable,now 2:3.42.1-1+deb10u5 amd64
  Network Security Service libraries

libnss3-dev/oldstable 2:3.42.1-1+deb10u5 amd64
  Development files for the Network Security Service libraries

libnss3-tools/oldstable 2:3.42.1-1+deb10u5 amd64
  Network Security Service tools

nss-passwords/oldstable 0.2-2+b2 amd64
  read passwords from a Mozilla keyring
  1. Install the candidate
sudo apt install -y libnss3
  1. Run your command again

If the error message goes away => success

If the error message changes => repeat for the new error message

If the error message does not change => the library you installed didn't have the files you need, so uninstall and try a different one

# Uninstall the package and delete its configuration files
sudo apt purge -y libnss3
# Uninstall dangling dependencies
sudo apt autoremove -y

See also man apt-get

Sukkah answered 9/2, 2022 at 19:21 Comment(5)
Did not work for me with wsl2 unfortunately. Thanks anywaysEndogamy
Purging libnss3 took a hell of a lot of software with it. Basically everything written in Java... Would not recommend.Wold
Hi, I am also facing same while running on Jenkins ci/CD and my repo on gitlab. Can you please let me know where I need to install libnss3.so and where I need to run sudo apt install -y libnss3....?Castra
Thank you for your well explained answerDelocalize
@Wold I think you are mistaken. The only difference between purge and remove is that purge also deletes configuration files; neither have the ability to uninstall other unspecified packages. Maybe you also ran autoremove and other software was uninstalled. This is as expected especially if you haven't run it before, since the purpose of it is to remove dangling dependencies. Please refer to the man page man apt-get if you have any questions. I will add brief comment on those lines for people who may be less familiar.Sukkah
F
10

You need to satisfy the libraries dependencies to run chrome in a headless mode:

sudo apt-get update && sudo apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libnss3 lsb-release xdg-utils wget ca-certificates

For more

Flores answered 15/9, 2022 at 15:1 Comment(1)
It looks like this is what was needed to get my nvm working on windows w/ WSLMoorman
L
0

The following works for Debian 10 (in bare metal, VirtualBox, and distrobox) without running sudo apt --fix-broken install:

sudo apt update && sudo apt full-upgrade && \
sudo apt-get install -y \
gconf-service \
libasound2 \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgcc1 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
ca-certificates \
fonts-liberation \
libnss3 \
lsb-release \
xdg-utils \
wget \
ca-certificates \
lib32gcc1 \
lib32stdc++6 \
libc6-i386 \
libclang-7-dev \
libclang-common-7-dev \
libclang-dev \
libclang1-7 \
libgc1c2 \
libobjc-8-dev  \
libobjc4 \
libpq5 \
libxcb-xkb1 \
libxkbcommon-x11-0
Lucarne answered 11/10, 2023 at 15:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.