How to install X11 before testing with GitHub Actions for macOS?
Asked Answered
M

2

12

I'm testing an R package with GitHub Actions, and it succeeds on Windows and Linux.

However, it fails on Mac OS, as you can see on the logs:

  Warning in grSoftVersion() :
    unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':
    dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib
    Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/modules/R_X11.so
    Reason: image not found
  Warning in cairoVersion() :
    unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so':
    dlopen(/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so, 6): Library not loaded: /opt/X11/lib/libXrender.1.dylib
    Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/grDevices/libs/cairo.so
    Reason: image not found
  Warning in png(filename = file, width = width, height = height, units = "in",  :
    failed to load cairo DLL
  Error in external_img(new_src, width = width, height = height) : 
    src must be a string starting with 'rId' or an image filename
  Calls: %>% ... <Anonymous> -> body_add_gg -> body_add_img -> external_img
  Execution halted

I don't own a Mac computer, don't plan to do so in the future, so I cannot test it myself.

As I could see on include cairo R on a mac, this is probably due to X11 not being installed on the testing machine.

How can I tell GitHub Actions that this code depends on X11?

EDIT:

Here is my GitHub Actions config file: link. Adding this code fixed the problem:

  - name: Install X11 dependencies on MacOS
    if: runner.os == 'macOS'
    run: |
      brew --cask install xquartz
Machinate answered 29/8, 2020 at 15:19 Comment(0)
P
9

Homebrew is there on the GitHub Actions default VMs,

https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md

So you can install X11 via homebrew with

brew cask install xquartz

https://formulae.brew.sh/cask/xquartz

before executing your R testing.

Phebe answered 29/8, 2020 at 16:16 Comment(2)
Thanks for your answer, had to work out how to include this line in the config file but now it works just fine :-)Machinate
Here was the command I had to use to install X11 and XQuartz via GitHub Actions: brew install --cask xquartzWetzell
A
2

What worked for me was adding this to the workflow file:

      - name: Install XQuartz on macOS
        if: runner.os == 'macOS'
        run: brew install xquartz --cask

I found this info here, and adapted it using this comment (as the original code didn't work, it errored).

Aback answered 26/8, 2021 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.