Search code examples
ryamltravis-cidevtools

Travis CI error while devtools::chech() doesn't


Here is the package in github.

As you can see in travis.yml, warnings are not treated as errors. When I do the check() in console, there are no errors. Here is the result:

0 errors ✓ | 4 warnings x | 1 note x

And here are the last lines of Travis CI.

ERROR: dependency ‘raster’ is not available for package ‘leaflet’
* removing ‘/home/travis/R/Library/leaflet’
* installing *source* package ‘modelr’ ...
** package ‘modelr’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (modelr)
* installing *source* package ‘tidyverse’ ...
** package ‘tidyverse’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (tidyverse)
The downloaded source packages are in
    ‘/tmp/RtmpX59PJA/downloaded_packages’
Warning messages:
1: In i.p(...) : installation of package ‘terra’ had non-zero exit status
2: In i.p(...) : installation of package ‘units’ had non-zero exit status
3: In i.p(...) : installation of package ‘raster’ had non-zero exit status
4: In i.p(...) : installation of package ‘sf’ had non-zero exit status
5: In i.p(...) :
  installation of package ‘leaflet’ had non-zero exit status
missing: terra, raster, units, leaflet, sf
The command "Rscript -e 'deps <- remotes::dev_package_deps(dependencies = NA);remotes::install_deps(dependencies = TRUE);if (!all(deps$package %in% installed.packages())) { message("missing: ", paste(setdiff(deps$package, installed.packages()), collapse=", ")); q(status = 1, save = "no")}'" failed and exited with 1 during .
Your build has been stopped.

What should I modify to get the it pass through Travis CI ?


Solution

  • I would seem that your package depends, at least, on raster and sf; and your script does not install them:

    1: In i.p(...) : installation of package ‘terra’ had non-zero exit status
    2: In i.p(...) : installation of package ‘units’ had non-zero exit status
    3: In i.p(...) : installation of package ‘raster’ had non-zero exit status
    4: In i.p(...) : installation of package ‘sf’ had non-zero exit status
    

    The reason is most likely that you do not install the required system dependencies (GDAL, GEOS, ...). You need to add something like this to your system before installing these packages

    sudo apt-get install libgdal-dev libproj-dev libgeos-dev libudunits2-dev netcdf-bin

    I think that in a travis file that goes like this

    addons:
      apt:
        packages:
          - libgdal-dev
          - libproj-dev
          - libudunits2-dev
          - netcdf-bin
    

    You may prefer using github actions. See e.g. this workflow for terra