Search code examples
rtravis-cigdalr-packagergdal

Finding/specifying Installation path of gdal in a travis-ci build


in a package I am maintaining (https://github.com/lbusett/MODIStsp), I use the gdalUtils package as a wrapper to gdal utilities. The problem is that I can not find a way to run my test suite and examples on TRAVIS-CI. This appears to e related to the fact that the gdal installation folder is not found on the path, so that I receive the following error:

Warning in gdalUtils::gdal_setInstallation(ignore.full_scan = TRUE)
No GDAL installation found. Please install 'gdal' before continuing:
- www.gdal.org (no HDF4 support!)
- www.trac.osgeo.org/osgeo4w/ (with HDF4 support RECOMMENDED)
- www.fwtools.maptools.org (with HDF4 support)

(see here for the full build log: https://travis-ci.org/lbusett/MODIStsp/jobs/318037312)

gdalUtils::gdal_setInstallation() is supposed to search for a valid gdal installation, by first using sys.which(), and (incase it fails) looking on "typical" installation paths (see https://www.rdocumentation.org/packages/gdalUtils/versions/2.0.1.7/topics/gdal_setInstallation).

This happens besides gdal (apparently) being installed on travis in the build, using the following travis.yml configuration:

{
  "language": "r",
  "cache": "packages",
  "warnings_are_errors": false,
  "before_install": [
    "sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes",
    "sudo add-apt-repository -y ppa:opencpu/jq --yes",
    "sudo apt-get -qq update",
    "sudo apt-get install -y libgdal-dev libproj-dev",
    "export DISPLAY=:99.0",
    "sh -e /etc/init.d/xvfb start"
  ],
  "group": "stable",
  "dist": "trusty",
  "apt_packages": [
    "libgdal-dev",
    "libproj-dev",
    "libcairo2-dev",
    "libatk1.0-dev",
    "libpango1.0-dev",
    "libgtk2.0-dev",
    "libglib2.0-dev",
    "libcurl4-openssl-dev"
  ],
  "env": "global=[\"R_LIBS=\\\"http://cran.rstudio.com\\\"\", \"R_BUILD_ARGS=\\\"--no-build-vignettes --no-manual\\\"\", \"R_CHECK_ARGS=\\\"--no-build-vignettes --no-manual --as-cran\\\"\", \"R_CHECK_TIMINGS_=\\\"0\\\"\", \"BOOTSTRAP_LATEX=\\\"1\\\"\"]",
  "os": "linux",
  "r_binary_packages": [
    "cairoDevice",
    "RGtk2"
  ],
  "sudo": "required"
}

Do you have any suggestions to solve the issue? Do I need to somehow set the PATH to gdal in the travis.yml script? If so, how could I find out where gdal is being installed? (I tried adding a line like "PATH=\"/usr/local/gdal/bin:$PATH\"" in the yml but it did not work.

Thanks in advance for any help!


Solution

  • In the end the issue was solved by simply adding installation of gdal-bin in the yaml trough:

    sudo apt-get install -y gdal-bin

    (thanks to Benjamin for providing the solution on the r-pkg-devel mailing list)