<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: LooseChangeLabs</title>
    <description>The latest articles on DEV Community by LooseChangeLabs (@loosechangelabs).</description>
    <link>https://dev.to/loosechangelabs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4130968%2F2aa60956-dde7-402f-aa7a-54bcc8bd1635.png</url>
      <title>DEV Community: LooseChangeLabs</title>
      <link>https://dev.to/loosechangelabs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/loosechangelabs"/>
    <language>en</language>
    <item>
      <title>Fixing "error while loading shared libraries: libnspr4.so" for Playwright with no root access</title>
      <dc:creator>LooseChangeLabs</dc:creator>
      <pubDate>Fri, 18 Sep 2026 06:45:10 +0000</pubDate>
      <link>https://dev.to/loosechangelabs/fixing-error-while-loading-shared-libraries-libnspr4so-for-playwright-with-no-root-access-2fg0</link>
      <guid>https://dev.to/loosechangelabs/fixing-error-while-loading-shared-libraries-libnspr4so-for-playwright-with-no-root-access-2fg0</guid>
      <description>&lt;p&gt;I was setting up browser automation for an AI coding agent running in a locked-down sandbox this week — no &lt;code&gt;sudo&lt;/code&gt;, no passwordless root, nothing. &lt;code&gt;npx playwright install --with-deps chromium&lt;/code&gt; failed immediately, and running the browser directly threw this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;error while loading shared libraries: libnspr4.so: cannot open shared object file: No such file or directory
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it happens
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;playwright install --with-deps&lt;/code&gt; and &lt;code&gt;playwright install-deps&lt;/code&gt; both shell out to &lt;code&gt;apt-get install&lt;/code&gt; under the hood, which needs root. No root, no install, no browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: apt-get download doesn't need root
&lt;/h2&gt;

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

&lt;ol&gt;
&lt;li&gt;Ask Playwright what it thinks is missing: &lt;code&gt;npx playwright install-deps chromium --dry-run&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;apt-get download&lt;/code&gt; each package listed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dpkg-deb -x&lt;/code&gt; them into a local prefix, e.g. &lt;code&gt;~/.local/playwright-libs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Point the browser at it with &lt;code&gt;LD_LIBRARY_PATH&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Nothing touches &lt;code&gt;/usr&lt;/code&gt;, nothing needs sudo, and deleting the prefix directory undoes all of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  I packaged this as a script
&lt;/h2&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/LooseChangeLabs/rootless-playwright" rel="noopener noreferrer"&gt;https://github.com/LooseChangeLabs/rootless-playwright&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./install.sh chromium
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>docker</category>
      <category>devops</category>
      <category>ci</category>
    </item>
  </channel>
</rss>
