如何在使用 GitHub Actions for macOS 进行测试之前安装 X11?
How to install X11 before testing with GitHub Actions for macOS?
我正在使用 GitHub 操作测试 R 包,它在 Windows 和 Linux 上成功。
但是,它在 Mac OS 上失败了,正如您在 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
我没有 Mac 电脑,以后不打算这样做,所以我无法自己测试。
正如我在 上看到的,这可能是由于测试机器上没有安装 X11。
如何告诉 GitHub Actions 此代码依赖于 X11?
编辑:
这是我的 GitHub 操作配置文件:link。添加此代码解决了问题:
- name: Install X11 dependencies on MacOS
if: runner.os == 'macOS'
run: |
brew --cask install xquartz
Homebrew 在 GitHub Actions 默认 VM 上,
https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md
因此您可以使用
通过自制软件安装 X11
brew cask install xquartz
https://formulae.brew.sh/cask/xquartz
在执行 R 测试之前。
对我有用的是将其添加到工作流文件中:
- name: Install XQuartz on macOS
if: runner.os == 'macOS'
run: brew install xquartz --cask
我找到了这个信息 here, and adapted it using this 评论(因为原始代码不起作用,所以出错了)。
我正在使用 GitHub 操作测试 R 包,它在 Windows 和 Linux 上成功。
但是,它在 Mac OS 上失败了,正如您在 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
我没有 Mac 电脑,以后不打算这样做,所以我无法自己测试。
正如我在
如何告诉 GitHub Actions 此代码依赖于 X11?
编辑:
这是我的 GitHub 操作配置文件:link。添加此代码解决了问题:
- name: Install X11 dependencies on MacOS
if: runner.os == 'macOS'
run: |
brew --cask install xquartz
Homebrew 在 GitHub Actions 默认 VM 上,
https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md
因此您可以使用
通过自制软件安装 X11brew cask install xquartz
https://formulae.brew.sh/cask/xquartz
在执行 R 测试之前。
对我有用的是将其添加到工作流文件中:
- name: Install XQuartz on macOS
if: runner.os == 'macOS'
run: brew install xquartz --cask
我找到了这个信息 here, and adapted it using this 评论(因为原始代码不起作用,所以出错了)。