Cairo and XQuartz in Mac GitHub Actions

Including cairo and xquartz in MacOS github actions

random-code-snippets
cairo
xquartz
development
github
R
Author

Robert M Flight

Published

January 6, 2022

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 {cairo.so} 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 {cairo.so} available.

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

    steps:
      - name: Install X11 dependencies on MacOS
        if: runner.os == 'macOS'
        run: |
          brew install --cask xquartz

References

“Homebrew.” 2022. https://brew.sh/.
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. https://CRAN.R-project.org/package=Cairo.
“Xquartz Homebrew Formulae.” 2022. https://formulae.brew.sh/cask/xquartz#default.

Reuse

Citation

BibTeX citation:
@online{mflight2022,
  author = {Robert M Flight},
  title = {Cairo and {XQuartz} in {Mac} {GitHub} {Actions}},
  date = {2022-01-06},
  url = {https://rmflight.github.io/posts/2022-01-06-cairo-and-xquartz-in-mac-github-actions},
  langid = {en}
}
For attribution, please cite this work as:
Robert M Flight. 2022. “Cairo and XQuartz in Mac GitHub Actions.” January 6, 2022. https://rmflight.github.io/posts/2022-01-06-cairo-and-xquartz-in-mac-github-actions.