Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 385
Dan Chaltiel Avatar asked Aug 29 '20 15:08

Dan Chaltiel


People also ask

How do I run a tox test in GitHub actions?

With GitHub Actions, you can run tests with tox and spread the work across multiple jobs. You'll need to invoke tox using the -e py option to choose the version of Python in your PATH, rather than specifying a specific version. For more information, see tox. You can upload artifacts to view after a workflow completes.

What do I need to use xcodebuild?

To use xcodebuild, you’ll need to have xcode installed – and with github actions, that’s available through virtualized instances of macOS with Xcode (and a lot of other tools) pre-installed.

Are GitHub actions too expensive to run?

If you’re running GitHub actions in a private repository (and paying for the privilege) you may find it just too expensive. The billing information for github actions shows that running macOS virtual images is 10 times the price of running Linux images ($0.08 per minute vs. $0.008 per minute).

How do I build iOS apps on Xcode?

If you want to build a macOS, tvOS, iOS, or even watchOS application, use xcodebuild. xcodebuild is the command-line invocation that uses the build toolchain built into xcode, leveraging all the built in mechanisms with targets, schemes, build settings, and overlays interactions with the simulators.


Video Answer


2 Answers

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.

like image 134
Lex Li Avatar answered Oct 16 '22 00:10

Lex Li


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

like image 23
stevec Avatar answered Oct 16 '22 01:10

stevec