quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.82k stars 309 forks source link

Quarto deos not find chromium if installed through flatpak #2980

Open ralmond opened 1 year ago

ralmond commented 1 year ago

Bug description

Quarto apparently requires Chrome or Chromium to render graphviz documents, but on Pop_OS 22.04, chromium is only available through flatpak. The search method in puppeteer.ts#findChrome don't find the flatpak installation.

Steps to reproduce (Debian Linux assumed): 1) Uninstall Chrome/Chromium installed through deb package or quarto tools install chromium (this should remove chromium-browser from the path. 2) Install chromium using flatpak install org.chromium.Chromium (note, run this as user, not root). 3) Verify that chromium runs by executing flatpak run org.chromium.Chromium 4) Attempt to use quarto to render foo.qmd (attached). This will generate the error.

foo.qmd.txt

I'm getting this error with RStudio 2022.07.0+548 "Spotted Wakerobin" Release (34ea3031089fa4e38738a9256d6fa6d70629c822, 2022-07-06) for Ubuntu Jammy Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36 and quarto version 1.0.37

Some quick tests with my machine verify that the command flatpak info org.chromium.Chromium can be used to test that chromium is installed using flatpak (and which flatpak can be used to test for flatpak. The info command will return an error if chromium is not installed. If it is installed, it can be launched using flatpak run org.chromium.Chromium ... where ... are the usual command line arguments.

Checklist

ralmond commented 1 year ago

I just verified that I can work around this issue by adding the following command:

$ cat >chromium-browser <<EOF
#!/bin/sh
flatpak run org.chromium.Chromium $*
EOF
$ chmod +x chromium-browser
$ mv chromium-browser $HOME/.local/bin

It would be better, however, to fix the findChrome function to search for flatpak (and probably snap as well) installations.

cscheid commented 1 year ago

Thanks for the report, and I'm glad the workaround is there for you. If flatpak installations are such that chromium is not on the path, I'm not sure how the quarto codebase should respond. I'm personally relatively conservative wrt non-standard approaches like flatpak and snap (I'm aware of their popularity because of Ubuntu. They still don't appear to use the standard unix way of advertising binaries through PATH).

Newbytee commented 1 year ago

Flatpak does put "fake binaries" that can be executed in /var/lib/flatpak/exports/bin, but this is not added to path by default in most distributions. Additionally, they use the app ID of the Flatpak as name rather than just the binary name. So, for example Chromium has the executable name org.chromium.Chromium in that path.

ralmond commented 1 year ago

That directory is not available on my setup (this is the fairly standard Pop_OS).

My suggestion is that quarto tool install chromium should check for a version of Chromium installed via flatpack or snap, and if necessary add a shell script to launch the browser rather than install a second version of Chromium.

Newbytee commented 1 year ago

That directory is not available on my setup (this is the fairly standard Pop_OS).

Ubuntu is notorious for shipping outdated versions of Flatpak. Is this the case for Pop!_OS too?

cderv commented 3 months ago

I have opened an macro issue to track a proper solution