r - 安装 R 包时,R 如何检查系统外部依赖项?

标签 r

例如,在尝试安装 R 包时 curl作为 usethis 的依赖项:

* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'

R 检测到我没有安装 libcurl。这个外部部门在什么级别?指定的?我知道可以在描述文件中指示外部依赖项,并且确实 curl 的 pkg 描述文件确实包含:
SystemRequirements: libcurl: libcurl-devel (rpm) or libcurl4-openssl-dev (deb).

但是那一行是什么允许 R 检测丢失的依赖项并打印该错误?不可能吧?怎么可能?那么,R 是怎么做的呢?

最佳答案

简要地:

  • 这一切都在 Writing R Extension .
  • 简而言之,它不会,即 R 不会帮助你。见下文。
  • 可以声明 CRAN(和 Bioconductor)包依赖项。
  • 对于其他一切,您只能通过 SystemRequirements 进行估算。在 DESCRIPTION
  • 这不是一个已解决或可解决的问题,取决于所有操作系统
  • 所以其他语言也没有。
  • 人们可以获得的是“垂直”堆栈中的包管理器——比如 brewapt .这很好,但它也不适用于 CRAN 源代码级别。
  • 因此,正如您所展示的,我们所能做的就是调用名为 configure 的可执行文件。测试资源是否存在,如果不存在则以明确的错误中止。
  • 对于您展示的包裹,test code in configure is here .
  • 有一个 sibling Windows version too .
  • 关于r - 安装 R 包时,R 如何检查系统外部依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58291674/

    相关文章:

    r - 转换堆积密度图中每个因子的高度 (ggplot2)

    r - 绘制和保存 R 图

    R:根据排名重新排列数据框的列

    r - 为什么预测的输出是一个水平为 0 的因子?

    r - 为使用 facet_wrap (ggplot2) 创建的每个子图添加标签

    regex - 从 R 中的字符串中提取日期

    r - 如何使用 ggcoefstats 在 R 中呈现多个 BTERGM 的结果?

    xml - 将维基百科中的表格加载到 R

    r - 以方形马赛克打印一组图像

    html - Shiny 的 R : Alert message or modal dialog input:invalid