Process required for a working install on Forge provisioned servers (Digital Ocean) #137
Replies: 3 comments 2 replies
-
Working solution for meMaybe it will solve your problem too. Error OutputMy problem with Hetzner Cloud Ubuntu 22.04 and Laravel 11 Symfony\Component\Process\Exception\ProcessTimedOutException The process "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH= [115372:115372:0330/231700.707395:ERROR:zygote_host_impl_linux.cc(100)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180. |
Beta Was this translation helpful? Give feedback.
-
Hey @KS-Verbosity, I struggled a lot with getting this to work on my ubuntu server with openlitespeed, but I got it to work eventually, see this: #134 (comment) |
Beta Was this translation helpful? Give feedback.
-
I also encountered numerous issues getting "Spatie\LaravelPdf" to work on a remote server, even though everything worked perfectly right away on my local environment. P.S.: As you will notice, some actions are repeated, but I encountered error after error, and it was in this order that I resolved my issues. Troubleshooting Guide for Spatie\LaravelPdf and BrowsershotContextThe library "Spatie\LaravelPdf" uses "Browsershot", which depends on "Puppeteer" and "Chromium" to generate PDFs and screenshots. These dependencies require at least Node.js 22.0 to be installed on the server. Additional details can be found here: Issue on Hetzner ServersThere is a known issue on Hetzner servers where the URLs in the configuration files for updating internal packages are incorrect. If errors occur when running
Upgrading Node.js and NPMIf the installed version of Node.js is lower than 22:
Steps Taken to Resolve the IssueInstall Chromium and Configure Puppeteer# Install Chromium, as it's required by Puppeteer to render PDFs and screenshots
sudo apt install -y chromium-browser
# Set the environment variable for Puppeteer to use the installed Chromium browser
export PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Clear Puppeteer's cache to remove any corrupted or outdated files
rm -rf ~/.cache/puppeteer
# Force reinstall Puppeteer to ensure it is properly set up
npm install puppeteer --force Install Missing DependenciesChromium requires several system dependencies to function correctly. Install them using: # Sources:
# https://pptr.dev/guides/system-requirements
# https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/debian/dist_package_versions.json
sudo apt update && sudo apt install -y \
libasound2 \ # Audio support library
libatk-bridge2.0-0 \ # Accessibility toolkit bridge
libatk1.0-0 \ # Accessibility toolkit library
libgtk-3-0 \ # Graphical toolkit
libatspi2.0-0 \ # Assistive Technology Service Provider Interface
libc6 \ # GNU C library
libcairo2 \ # Vector graphics rendering library
libcups2 \ # Printing system support library
libdbus-1-3 \ # D-Bus IPC system
libdrm2 \ # Direct Rendering Manager
libexpat1 \ # XML parsing library
libgbm1 \ # Graphics buffer manager
libglib2.0-0 \ # GLib utilities
libnspr4 \ # Netscape Portable Runtime
libnss3 \ # Network Security Services
libpango-1.0-0 \ # Text layout and rendering
libpangocairo-1.0-0 \ # Pango library for Cairo rendering
libstdc++6 \ # Standard C++ library
libudev1 \ # Device management library
libuuid1 \ # UUID library
libx11-6 \ # X11 client-side library
libx11-xcb1 \ # X11-XCB utility
libxcb-dri3-0 \ # XCB Direct Rendering Infrastructure
libxcb1 \ # X protocol C-language binding
libxcomposite1 \ # X11 composite extension
libxcursor1 \ # X11 cursor management library
libxdamage1 \ # X11 damage extension
libxext6 \ # X11 miscellaneous extensions
libxfixes3 \ # X11 region manipulation library
libxi6 \ # X Input extension
libxkbcommon0 \ # Keyboard handling library
libxrandr2 \ # X Resize and Rotate extension
libxrender1 \ # X Rendering extension
libxshmfence1 \ # Shared memory fence synchronization
libxss1 \ # X11 screensaver extension
libxtst6 # X11 test extension Install Additional UtilitiesSome Chromium features require sudo apt install -y xdg-utils Resolve Chromium Installation Conflicts
Code Configuration for BrowsershotPdf::view('path.to.view', []) // Specify the view to render as a PDF
->withBrowsershot(function (Browsershot $browsershot) {
/*
* Only apply these configurations in non-development environments
* as the library works correctly in local environment
*/
if (!is_development()) {
$browsershot
->setChromePath('/usr/bin/chromium-browser') // Use manually installed Chromium
->setCustomTempPath(storage_path('temp')) // Custom temp directory for server compatibility
->noSandbox() // Disable sandbox for headless Chromium compatibility
->newHeadless(); // Run Chromium in headless mode
}
}); |
Beta Was this translation helpful? Give feedback.
-
What happened?
So far it has not been possible to get an application into production as all attempts at a Forge solution have failed. Many attempts have been made and at best the result is the same as what is listed in Discussion 93 - #93
Definitely looking for updated guidance. I will report any success if I find a solution.
How to reproduce the bug
Move a working Laravel 10 app with the PDF tool installed (from MacOS using Herd Pro). Everything works fine locally, but it has not been possible to get a working install done on a Forge server (Digital Ocean).
Package Version
1.1
PHP Version
8.2.15
Laravel Version
10.45.1
Which operating systems does with happen with?
Linux
Notes
Digital Ocean server
/home/forge/.nvm/versions/node/v21.7.1/bin/node
npm updated
Errors such as these are as close as it gets to working:
The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=
/home/forge/.nvm/versions/node/v21.7.1/bin/node /home/forge/.nvm/versions/node/v21.7.1/bin/npm root -g
/home/forge/.nvm/versions/node/v21.7.1/bin/node '/home/forge/xxx.com/vendor/spatie/browsershot/src/../bin/browser.cjs' ''" failed.Exit Code: 1(General error)
Error Output:
Error: net::ERR_FILE_NOT_FOUND at file:///tmp/106890602-0196505001711765888/index.html
at navigate (/home/forge/xxx.com/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Frame.js:171:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Deferred.race (/home/forge/xxx.com/node_modules/puppeteer-core/lib/cjs/puppeteer/util/Deferred.js:36:20)
at async CdpFrame.goto (/home/forge/xxx.com/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Frame.js:137:25)
at async CdpPage.goto (/home/forge/xxx.com/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:590:20)
Beta Was this translation helpful? Give feedback.
All reactions