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
2022-01-06

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
“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.

References

Corrections

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

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/rmflight/researchBlog_distill, 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 ...".

Citation

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 https://rmflight.github.io/posts/2022-01-06-cairo-and-xquartz-in-mac-github-actions/

BibTeX citation

@misc{flight2022cairo,
  author = {Flight, Robert M},
  title = {Deciphering Life: One Bit at a Time: Cairo and XQuartz in Mac GitHub Actions},
  url = {https://rmflight.github.io/posts/2022-01-06-cairo-and-xquartz-in-mac-github-actions/},
  year = {2022}
}