8

I am facing a particularly vexing problem with R package development. My own package, called 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).

But whenever the package is to be installed on Unix machines, it throws the error that ggstatsplot can't be downloaded because userfriendlyscience and MBESS can't be downloaded because gsl can't be downloaded. The same thing is also revealed on Travis continuous integration platform with virtual Unix machines, where the package build fails (https://travis-ci.org/IndrajeetPatil/ggstatsplot).

Now one way to solve this problem for the user on the Unix machine is to configure GSL (as described here: installing R gsl package on Mac), but I can't possibly expect every user of ggstatsplot to go through the arduous process of configuring GSL. I want them to just run install.packages("ggstatsplot") and be done with it.

So I would really appreciate if anyone can offer me any helpful advice as to how I can make my package user's life simpler by removing this problem at its source. Is there something I should include in the package itself that will take care of this on behalf of the user?

wibeasley
  • 5,000
  • 3
  • 34
  • 62
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
  • 1
    I don't think the situation is as bad as you make it out to be. The R `gsl` package is available in binary form for Mac, so that leaves Linux. GSL is packaged for most Linux distros, e.g., as `libgsl-dev` and `libgsl2` on Ubuntu. So, Mac and Windows users do `install.packages("ggstatsplot")` and Linux users do `apt-get install libgsl-dev libgsl2` followed by `install.packages("ggstatsplot")`. It all seems pretty typical to me. – Ista Mar 08 '18 at 03:38
  • @Ista Thanks for your input and glad to hear that it's not as big of an issue as I think it is. I personally don't work with either Mac or Linux, so this is based purely on CI platforms I'm using to check package build and am confused by the error on Mac but not on Windows. For example, doing `install.packages("ggstatsplot")` works with Windows, but **not** with Mac and I'm not sure why that's the case. In other words, why do Windows users not face the same problems as Mac and Ubuntu users. I've asked my colleagues with Macs to install my package and it fails every time, but never on Windows. – Indrajeet Patil Mar 08 '18 at 03:57
  • I don't have access to a Mac at the moment, but I'll check when I do. My assumption is that Windows users don't have problems because the R package is already built for them by CRAN. This applies to Mac users as well, so I would expect it to work there also. I'll check that when I can. – Ista Mar 08 '18 at 04:02
  • I checked on a Mac and `gsl` installs and works just fine. No installation of GSL is required. – Ista Mar 08 '18 at 15:24
  • @Ista Thanks for checking. Yes, that's because I pushed some new changes last night based on the answer posted below. Now the package installation works just fine with `osx`, but still has issues with `Linux` (https://travis-ci.org/IndrajeetPatil/ggstatsplot). Working on resolving that now. – Indrajeet Patil Mar 08 '18 at 15:27
  • No, this is not because of any change you made; my point is that the `gsl` R package installs fine on Mac. There also is nothing to resolve for Linux users; they just need to install system dependencies as usual, e.g., `libgsl-dev` in this case. *You* may wish to resolve travis-ci issues -- see https://docs.travis-ci.com/user/languages/r#APT-packages for that. – Ista Mar 08 '18 at 15:33

1 Answers1

11

This may not have a satisfying solution via changes to your R package (I'm not sure either way). If the gsl package authors (which include a former R Core member) didn't configure it to avoid a pre-req installation of a linux package, there's probably a good reason not to.

But it may be some consolation that most R+Linux users understand that some R packages first require installing the underlying Linux libraries (eg, through apt or dnf/yum).

Primary Issue: making it easy for the users to install

Try to be super clear on the GitHub readme and the CRAN INSTALL file. The gsl package has decent CRAN directions. This leads to the following bash code:

sudo apt-get install libgsl0-dev

The best example of clear (linux pre-req package) documentation I've seen is from the curl and sf packages. sf's CRAN 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). For example, it provides the following explanation and bash code:

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

sudo apt-get install -y libcurl-dev

Ideally your documentation would describe how do install the gsl linux package on multiple distributions.

Disclaimer: I've never developed a package that directly requires a Linux package, but I use them a lot. In case more examples would help, this doc includes a script I use to install stuff on new Ubuntu machines. Some commands were stated explicitly in the package documentation; some had little or no documentation, and required research.

edit 2018-04-07: I encountered my new favorite example: the sys package uses a config file to produce the following message in the R console. While installing 100+ packages on a new computer, it was nice to see this direct message, and not have to track down the R package and the documentation about its dependencies.

On Debian/Ubuntu this package requires AppArmor.

Please run: sudo apt-get install libapparmor-dev

Another good one is pdftools, that also uses a config file (and is also developed by Jeroen Ooms).

Secondary Issue: installing on Travis

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

Alternatively, I'm more familiar with telling travis to install the linux package, as demonstrated by curl's config file. As a bonus, this probably more closely replicates what typical users do on their own machines.

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

Follow up 2018-03-13 Indrajeet and I tweaked the travis file so it's working. Two sections were changed in the yaml file:

  1. The libgsl0-dev entry was added under the packages section (similar to the libcurl4-openssl-dev entry above).
  2. Packages were listed in the r_binary_packages section so they install as binaries. The build was timing out after 50 minutes, and now it's under 10 min. In this particular package, the r_binary_packages section was nested in the Linux part of the Travis matrix so it wouldn't interfere with his two OS X jobs on Travis.
Community
  • 1
  • 1
wibeasley
  • 5,000
  • 3
  • 34
  • 62
  • Thank you so much for your detailed answer and also for links to extensive documentation! The `curl` package's `travis.yml` file was especially useful. The installation now works for `osx`, but the build is still failing for `linux` machines (https://travis-ci.org/IndrajeetPatil/ggstatsplot). Trying to figure out how to resolve that now. – Indrajeet Patil Mar 08 '18 at 15:30
  • I think the `linux` build is working now, but it's still not succeeding (https://travis-ci.org/IndrajeetPatil/ggstatsplot/jobs/351456750) because of the following error - `The job exceeded the maximum time limit for jobs, and has been terminated.` Any ideas about how to get around that? – Indrajeet Patil Mar 10 '18 at 16:53
  • These instructions did something but did not result in an installation of GSL that could be found by the r package `gsl`. When I follow the instructions at https://stackoverflow.com/questions/69583193/installing-r-gsl-package-on-ubuntu all went well and GSL appeared in a location where gsl could find it. – IRTFM Oct 29 '21 at 05:50