Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)```
like image 498
shaurya Avatar asked Sep 27 '19 12:09

shaurya


2 Answers

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

like image 186
Abhijay007j Avatar answered Nov 19 '22 02:11

Abhijay007j


When you see this kind of thing, it means your OS is missing low-level libraries that are expected. This happens a bit with WSL because aside from WSLg it doesn't have a graphical environment and also the OS distributions are very minimal.

To resolve this (Debian/Ubuntu example),

  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

sudo apt purge -y libnss3 && sudo apt autoremove
like image 31
Ders Avatar answered Nov 19 '22 03:11

Ders