[nu-demo] hero_books PDF export needs Chromium — Ubuntu 24 ships chromium-browser as snap-wrapper which fails on TF Grid VMs #177

Closed
opened 2026-04-24 16:31:58 +00:00 by mik-tf · 1 comment
Owner

Symptom

Clicking 'Generate PDF' inside a book in the hero_books UI returns:

PDF generation failed: RPC error: {"code":-32000,"message":"PDF generation failed: Chrome not available: Failed to run apt update: No such file or directory (os error 2). Please install Chrome manually."}

hero_books uses the headless_chrome Rust crate to render book pages into a single PDF. It expects a Chromium binary somewhere on PATH.

Root cause

On Ubuntu 24.04 (TF Grid flist), apt install chromium-browser installs a snap wrapper (package version 2:1snap1-0ubuntu2). When invoked, it prints:

Command '/usr/bin/chromium-browser' requires the chromium snap to be installed.
Please install it with:  snap install chromium

But snapd doesn't work cleanly on TF Grid flists — they don't have a systemd user session to run snap confinement. Even if snap install succeeds, the sandbox fails at runtime.

Debian's chromium package (non-snap) also isn't in Ubuntu 24 Noble's archive.

Options (ordered by pragmatism)

1. Install Google Chrome direct .deb

Google publishes .deb for Chrome Stable. Adds a repo key + adds chrome to apt, installs cleanly, no snap:

wget -qO - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg
echo 'deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list
apt update && apt install -y google-chrome-stable

Then configure hero_books to use /usr/bin/google-chrome-stable (via env var — check headless_chrome crate for how to override).

2. Bundle a Chromium binary at install time

hero_skills installer downloads a static Chromium build (e.g. from Thorium or Puppeteer's bundled Chromium) into /data/opt/chromium/ and sets PATH. ~150 MB download, no apt coupling.

3. Replace hero_books PDF generation with a non-Chromium path

Use weasyprint, wkhtmltopdf, or typst to render book pages → PDF. Each has tradeoffs (weasyprint needs Cairo + Pango, wkhtmltopdf needs Qt/WebKit, typst is fast but different from HTML rendering — book may not look identical).

Note: home#161 already installed typst on herodemo for pandoc. Reusing it for hero_books is a natural extension.

4. Drop PDF export entirely

hero_books' web UI can already show pages HTML one at a time. 'Export whole book as PDF' is a nice-to-have, not blocking the demo. Remove the button + endpoint until Chromium or a replacement lands.

Demo impact

hero_books works for browsing/reading (Knowledge World → library cards → pages). Only the 'PDF' button fails.

The Office archipelago's PDF island has a DIFFERENT missing dep — OnlyOffice Document Server — which is tracked separately in home#174. Don't conflate: hero_books PDF export = Chromium; Office PDF viewing = OnlyOffice.

  • home#128 — apt deps gap
  • home#161 — disaster recovery + typst already on /data
  • home#174 — OnlyOffice for Office PDFs (separate)

Signed-off-by: mik-tf

## Symptom Clicking 'Generate PDF' inside a book in the hero_books UI returns: ``` PDF generation failed: RPC error: {"code":-32000,"message":"PDF generation failed: Chrome not available: Failed to run apt update: No such file or directory (os error 2). Please install Chrome manually."} ``` hero_books uses the `headless_chrome` Rust crate to render book pages into a single PDF. It expects a Chromium binary somewhere on PATH. ## Root cause On Ubuntu 24.04 (TF Grid flist), `apt install chromium-browser` installs a **snap wrapper** (package version `2:1snap1-0ubuntu2`). When invoked, it prints: ``` Command '/usr/bin/chromium-browser' requires the chromium snap to be installed. Please install it with: snap install chromium ``` But snapd doesn't work cleanly on TF Grid flists — they don't have a systemd user session to run snap confinement. Even if snap install succeeds, the sandbox fails at runtime. Debian's `chromium` package (non-snap) also isn't in Ubuntu 24 Noble's archive. ## Options (ordered by pragmatism) ### 1. Install Google Chrome direct .deb Google publishes `.deb` for Chrome Stable. Adds a repo key + adds chrome to apt, installs cleanly, no snap: ```bash wget -qO - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg echo 'deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list apt update && apt install -y google-chrome-stable ``` Then configure hero_books to use `/usr/bin/google-chrome-stable` (via env var — check headless_chrome crate for how to override). ### 2. Bundle a Chromium binary at install time hero_skills installer downloads a static Chromium build (e.g. from [Thorium](https://thorium.rocks/) or [Puppeteer's bundled Chromium](https://storage.googleapis.com/chromium-browser-snapshots/)) into `/data/opt/chromium/` and sets PATH. ~150 MB download, no apt coupling. ### 3. Replace hero_books PDF generation with a non-Chromium path Use weasyprint, wkhtmltopdf, or typst to render book pages → PDF. Each has tradeoffs (weasyprint needs Cairo + Pango, wkhtmltopdf needs Qt/WebKit, typst is fast but different from HTML rendering — book may not look identical). Note: [home#161](https://forge.ourworld.tf/lhumina_code/home/issues/161) already installed typst on herodemo for pandoc. Reusing it for hero_books is a natural extension. ### 4. Drop PDF export entirely hero_books' web UI can already show pages HTML one at a time. 'Export whole book as PDF' is a nice-to-have, not blocking the demo. Remove the button + endpoint until Chromium or a replacement lands. ## Demo impact hero_books works for browsing/reading (Knowledge World → library cards → pages). Only the 'PDF' button fails. The Office archipelago's PDF island has a DIFFERENT missing dep — OnlyOffice Document Server — which is tracked separately in [home#174](https://forge.ourworld.tf/lhumina_code/home/issues/174). Don't conflate: hero_books PDF export = Chromium; Office PDF viewing = OnlyOffice. ## Related - [home#128](https://forge.ourworld.tf/lhumina_code/home/issues/128) — apt deps gap - [home#161](https://forge.ourworld.tf/lhumina_code/home/issues/161) — disaster recovery + typst already on /data - [home#174](https://forge.ourworld.tf/lhumina_code/home/issues/174) — OnlyOffice for Office PDFs (separate) Signed-off-by: mik-tf
Author
Owner

Resolved by lhumina_code/hero_skills@7c823d1 (PR lhumina_code/hero_skills#126).

Part of Phase 2 tracker #185.

Resolved by https://forge.ourworld.tf/lhumina_code/hero_skills/commit/7c823d1 (PR https://forge.ourworld.tf/lhumina_code/hero_skills/pulls/126). Part of Phase 2 tracker https://forge.ourworld.tf/lhumina_code/home/issues/185.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/home#177
No description provided.