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?
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
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.
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.
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).
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With