由于缺少 GSL,R 包构建在 Unix 机器上失败 - GNU Scientific Library

R package build failing on Unix machines due to missing GSL - GNU Scientific Library

我在 R 包开发方面遇到了一个特别棘手的问题。我自己的包,叫做ggstatsplot (https://github.com/IndrajeetPatil/ggstatsplot), depends on userfriendlyscience, which depends on another package called MBESS, which itself ultimately depends on another package called gsl. There is no problem at all for installation of ggstatsplot on a Windows machine (as assessed by AppVeyor continuous integration platform: https://ci.appveyor.com/project/IndrajeetPatil/ggstatsplot)。

但是每当要在 Unix 机器上安装软件包时,它会抛出 ggstatsplot 无法下载的错误,因为 userfriendlyscienceMBESS 无法下载,因为 gsl 无法下载。同样的事情也出现在 Travis 与虚拟 Unix 机器的持续集成平台上,其中包构建失败 (https://travis-ci.org/IndrajeetPatil/ggstatsplot)。

现在,为 Unix 机器上的用户解决此问题的一种方法是配置 GSL(如此处所述: installing R gsl package on Mac),但我不可能期望 ggstatsplot 的每个用户都经历配置 GSL 的艰巨过程。我希望他们只是 运行 install.packages("ggstatsplot") 并完成它。

因此,如果有人能向我提供任何有用的建议,告诉我如何通过从源头上解决这个问题来简化我的软件包用户的生活,我将不胜感激。我应该在包本身中包含一些东西来代表用户处理这个问题吗?

这可能无法通过更改您的 R 包来获得令人满意的解决方案(我不确定哪种方式)。如果 gsl 包作者(包括前 R Core 成员)没有配置它来避免 pre-req 安装 linux 包,可能有充分的理由不这样做。

但令人欣慰的是,大多数 R+Linux 用户了解某些 R 包首先需要安装底层 Linux 库(eg,通过apt or dnf/yum).

主要问题:方便用户安装

尽量在 GitHub 自述文件和 CRAN INSTALL file. The gsl package has decent CRAN directions 上写得非常清楚。这导致以下 bash 代码:

sudo apt-get install libgsl0-dev

我见过的清晰(linux pre-req 包)文档的最佳示例来自 curlsf 包。 sfCRAN page lists only the human names of the 3 libraries, but the GitHub page provides the exact bash commands for three major distribution branches. The curl package does this very well too (eg, CRAN and GitHub)。例如,它提供了以下解释和 bash 代码:

Installation from source on Linux requires libcurl. On Debian or Ubuntu use libcurl4-openssl-dev:

sudo apt-get install -y libcurl-dev

理想情况下,您的文档将描述如何在多个发行版上安装 gsl linux 包。

免责声明:我从未开发过直接需要 Linux 包的包,但我经常使用它们。如果更多示例会有所帮助,this doc 包括一个我用来在新 Ubuntu 机器上安装东西的脚本。包文档中明确说明了一些命令;有些文件很少或没有文件,需要研究。

编辑 2018-04-07: 我遇到了我最喜欢的新示例:sys package uses a config 文件在 R 控制台中生成以下消息。在一台新计算机上安装 100 多个包时,很高兴看到这条直接消息,而不必追踪 R 包和有关其依赖项的文档。

On Debian/Ubuntu this package requires AppArmor.

Please run: sudo apt-get install libapparmor-dev

另一个不错的是 pdftools, that also uses a config file (and is also developed by Jeroen Ooms).

次要问题:在 Travis 上安装

userfriendly travis config file apparently installs a lot of binaries directly (including gsl), unlike the current ggstatsplot version.

或者,我更熟悉告诉 travis 安装 linux 包,如 curl's config file 所示。作为奖励,这可能更接近地复制了典型用户在他们自己的机器上所做的事情。

addons:
  apt:
    packages:
    - libcurl4-openssl-dev

跟进 2018-03-13 Indrajeet 和我调整了 travis 文件,使其正常工作。 Two sections were changed在yaml文件中:

  1. libgsl0-dev 条目已添加到 packages 部分下(类似于上面的 libcurl4-openssl-dev 条目)。
  2. 包在 r_binary_packages 部分中列出,因此它们作为二进制文件安装。构建在 50 分钟后超时,现在不到 10 分钟。在这个特定的包中,r_binary_packages 部分嵌套在 Travis 矩阵的 Linux 部分,因此它不会干扰他在 Travis 上的两个 OS X 作业。