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

> Source: <https://dev.to/loosechangelabs/fixing-error-while-loading-shared-libraries-libnspr4so-for-playwright-with-no-root-access-2fg0>
> Published: 2026-09-18 06:45:10+00:00

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 loading 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 listed`dpkg-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](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.
