Cairo and XQuartz in Mac GitHub Actions

random-code-snippets cairo xquartz development github R

Including cairo and xquartz in MacOS github actions

Robert M Flight true

I’ve been using GitHub actions to check and test some of my R packages on multiple architectures, which is nice because I work primarily on Linux.

One recent package uses the {Cairo} package to generate images that are subsequently used for visualization (Urbanek and Horner 2020).

Interestingly, {Cairo} will install fine on MacOS, and then fail as soon as you do library(Cairo), complaining about not being able to load the {} file.

Thankfully, it seems that the GitHub actions MacOS VMs have homebrew (“Homebrew” 2022) installed, which means we can use the xquartz brew (“Xquartz Homebrew Formulae” 2022) to install it, and have {} available.

To add this to your GitHub actions yml, you should add these lines, and double check the brew syntax with the official docs.

      - name: Install X11 dependencies on MacOS
        if: runner.os == 'macOS'
        run: |
          brew install --cask xquartz
“Homebrew.” 2022.
Urbanek, Simon, and Jeffrey Horner. 2020. Cairo: R Graphics Device Using Cairo Graphics Library for Creating High-Quality Bitmap (PNG, JPEG, TIFF), Vector (PDF, SVG, PostScript) and Display (X11 and Win32) Output.
“Xquartz Homebrew Formulae.” 2022.



If you see mistakes or want to suggest changes, please create an issue on the source repository.


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Flight (2022, Jan. 6). Deciphering Life: One Bit at a Time: Cairo and XQuartz in Mac GitHub Actions. Retrieved from

BibTeX citation

  author = {Flight, Robert M},
  title = {Deciphering Life: One Bit at a Time: Cairo and XQuartz in Mac GitHub Actions},
  url = {},
  year = {2022}