cd /news/developer-tools/fixing-error-while-loading-shared-li… · home topics developer-tools article
[ARTICLE · art-133421] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Fixing "error while loading shared libraries: libnspr4.so" for Playwright with no root access

A developer published an MIT-licensed script that installs Playwright browser dependencies without root access by using apt-get download and dpkg-deb -x to unpack .deb packages into a local prefix and setting LD_LIBRARY_PATH. The tool, rootless-playwright, dynamically discovers the required package list from Playwright itself and verifies the browser launches, addressing the recurring libnspr4.so shared library error in restricted environments like containers and CI runners.

by read1 min views2 publishedSep 18, 2026

I was setting up browser automation for an AI coding agent running in a locked-down sandbox this week — no sudo, no passwordless root, nothing. npx playwright install --with-deps chromium failed immediately, and running the browser directly threw this:

error while  shared libraries: libnspr4.so: cannot open shared object file: No such file or directory

followed by the same error for another 30-odd libraries once you fix them one at a time. This is a known, recurring problem in restricted environments — containers, CI runners, and platforms like Render/Replit/Streamlit Cloud where you don't control the base image and can't apt-install anything.

playwright install --with-deps and playwright install-deps both shell out to apt-get install under the hood, which needs root. No root, no install, no browser.

apt-get install needs root because it writes into /usr. But apt-get download — which just fetches a .deb file — doesn't need root at all, and dpkg-deb -x will happily unpack that .deb's contents into any directory you own. So the fix is:

npx playwright install-deps chromium --dry-run apt-get download each package listeddpkg-deb -x them into a local prefix, e.g. ~/.local/playwright-libs LD_LIBRARY_PATH Nothing touches /usr, nothing needs sudo, and deleting the prefix directory undoes all of it.

Rather than re-run those steps by hand every time, I wrapped it into a small script that discovers the package list dynamically (not hardcoded — it actually asks Playwright), downloads everything, wires up the library path, and verifies the browser launches:

https://github.com/LooseChangeLabs/rootless-playwright

./install.sh chromium

It's MIT-licensed and free. If you're stuck with the same error, hopefully this saves you the trial-and-error I went through.

── more in #developer-tools 4 stories · sorted by recency
── more on @playwright 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/fixing-error-while-l…] indexed:0 read:1min 2026-09-18 ·