Laravel spatie pdf works well on Mac local env but upon deploying on Ubuntu server am getting some errors.
How to reproduce the bug
When I hit the endpoint to generate pdf I see the error below
Symfony \ Component \ Process \ Exception \ ProcessFailedException
The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=npm root -g node '/var/www/experts/backend/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:\/\/\/tmp\/512163753-0320285001705991912\/index.html","action":"pdf","options":{"args":[],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /var/www/experts/backend/public Output: ================ Error Output: ================ [1m[43m[30m Puppeteer old Headless deprecation warning:[0m[33m In the near future headless: true will default to the new Headless mode for Chrome instead of the old Headless implementation. For more information, please see https://developer.chrome.com/articles/new-headless/. Consider opting in early by passing headless: "new" to puppeteer.launch() If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.[0m Error: Could not find Chrome (ver. 119.0.6045.105). This can occur if either 1. you did not perform an installation before running the script (e.g. npx puppeteer browsers install chrome) or 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer). For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration. at ChromeLauncher.resolveExecutablePath (/var/www/experts/backend/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:278:27) at ChromeLauncher.executablePath (/var/www/experts/backend/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:209:25) at ChromeLauncher.computeLaunchArguments (/var/www/experts/backend/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:103:37) at async ChromeLauncher.launch (/var/www/experts/backend/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:69:28) at async callChrome (/var/www/experts/backend/vendor/spatie/browsershot/bin/browser.cjs:91:23)
Package Version
spatie/laravel-pdf version 1.1
PHP Version
8.1.27
Laravel Version
10.10
Which operating systems does with happen with?
Linux
Notes
This works well when developing on macOs locally. But fails on Ubuntu server.
What happened?
Laravel spatie pdf works well on Mac local env but upon deploying on Ubuntu server am getting some errors.
How to reproduce the bug
When I hit the endpoint to generate pdf I see the error below
Symfony \ Component \ Process \ Exception \ ProcessFailedException The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=
npm root -g
node '/var/www/experts/backend/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:\/\/\/tmp\/512163753-0320285001705991912\/index.html","action":"pdf","options":{"args":[],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /var/www/experts/backend/public Output: ================ Error Output: ================ [1m[43m[30m Puppeteer old Headless deprecation warning:[0m[33m In the near futureheadless: true
will default to the new Headless mode for Chrome instead of the old Headless implementation. For more information, please see https://developer.chrome.com/articles/new-headless/. Consider opting in early by passingheadless: "new"
topuppeteer.launch()
If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.[0m Error: Could not find Chrome (ver. 119.0.6045.105). This can occur if either 1. you did not perform an installation before running the script (e.g.npx puppeteer browsers install chrome
) or 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer). For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration. at ChromeLauncher.resolveExecutablePath (/var/www/experts/backend/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:278:27) at ChromeLauncher.executablePath (/var/www/experts/backend/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:209:25) at ChromeLauncher.computeLaunchArguments (/var/www/experts/backend/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:103:37) at async ChromeLauncher.launch (/var/www/experts/backend/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:69:28) at async callChrome (/var/www/experts/backend/vendor/spatie/browsershot/bin/browser.cjs:91:23)Package Version
spatie/laravel-pdf version 1.1
PHP Version
8.1.27
Laravel Version
10.10
Which operating systems does with happen with?
Linux
Notes
This works well when developing on macOs locally. But fails on Ubuntu server.