'"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)```
Solution 1:[1]
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
Solution 2:[2]
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),
- Search the package manager's packages for the one that is missing
apt search libnss3
- 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
- Install the candidate
sudo apt install -y libnss3
- 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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Abhijay007j |
| Solution 2 | Ders |
