Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

codebyshami's avatar

BROWSERSHOT NOT working on server

The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=npm root -g node '/var/www/franceduerp/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:///tmp/1403670041-0864025001727751018/index.html","action":"pdf","options":{"args":["----no-sandbox"],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"format":"ledger","executablePath":"/snap/bin/chromium","printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /var/www/franceduerp/public Output: ================ Error Output: ================ Error: Failed to launch the browser process! cmd_run.go:1129: WARNING: cannot create user data directory: cannot create snap home dir: mkdir /var/www/snap: permission denied /system.slice/php8.3-fpm.service is not a snap cgroup TROUBLESHOOTING: https://pptr.dev/troubleshooting at Interface.onClose (/usr/local/lib/node_modules/puppeteer/node_modules/@puppeteer/browsers/lib/cjs/launch.js:312:24) at Interface.emit (node:events:529:35) at Interface.close (node:internal/readline/interface:534:10) at Socket.onend (node:internal/readline/interface:260:10) at Socket.emit (node:events:529:35) at endReadableNT (node:internal/streams/readable:1400:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

0 likes
1 reply
amirulhakim5430's avatar

Same i got same error so

The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=/usr/bin/node /usr/bin/npm root -g /usr/bin/node '/srv/merchant-portal/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:///tmp/212316522-0932001001749457528/index.html","action":"pdf","options":{"args":["----disable-gpu","----disable-dev-shm-usage","----disable-setuid-sandbox","----no-first-run","----no-sandbox","----no-zygote","----single-process"],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"executablePath":"/usr/bin/chromium-browser","printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /srv/merchant-portal/public Output: ================ Error Output: ================ Error: Failed to launch the browser process! /system.slice/php8.4-fpm.service is not a snap cgroup TROUBLESHOOTING: #ttp replace /pptr.dev/troubleshooting at Interface.onClose (/srv/merchant-portal/node_modules/@puppeteer/browsers/lib/cjs/launch.js:325:24) at Interface.emit (node:events:529:35) at Interface.close (node:internal/readline/interface:534:10) at Socket.onend (node:internal/readline/interface:260:10) at Socket.emit (node:events:529:35) at endReadableNT (node:internal/streams/readable:1400:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

I solved just now after 3 days stuck on this

striderwhite on Nov 28, 2024 @slakbal I found a workaround, just install google chrome directly (without a package manager) and use that. Here are some instructions

download chrome package

wget #ttpreplace . dl.google. com/linux/direct/google-chrome-stable_current_amd64.deb

try installing it, if it gives errors, install and missing deps, I had to install fonts-liberation after running this:

sudo dpkg -i google-chrome-stable_current_amd64.deb

for me I had to install this missing dep

sudo apt-get install fonts-liberation

install (again) if needed

sudo dpkg -i google-chrome-stable_current_amd64.deb

remove old file

rm -rf google-chrome-stable_current_amd64.deb

check if it installed

google-chrome-stable --version

now find the path, use this when pointing browsershot/whatever

whereis google-chrome

probably is /usr/bin/google-chrome

EX:

$browsershot->setChromePath('/usr/bin/google-chrome');

This works

Please or to participate in this conversation.