skip to Main Content

Trying to create a docker container for a shiny app and rgdal isn’t installing properly.

Ubuntu ver:

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic

I’m using renv with the system like https://www.statworx.com/de/blog/how-to-dockerize-shinyapps/

The Dockerfile looks like this:

cat Dockerfile
#get the base image
#FROM rocker/shiny:latest

#try with r-ver to make it smaller
FROM rocker/r-ver:latest

# system libraries of general use
## install debian packages
RUN apt-get update -qq && apt-get -y --no-install-recommends install 
    libxml2-dev 
    libcairo2-dev 
    libsqlite3-dev 
    libpq-dev 
    libssh2-1-dev 
    unixodbc-dev 
    r-cran-v8 
    libv8-dev 
    net-tools 
    libprotobuf-dev 
    protobuf-compiler 
    libjq-dev 
    libudunits2-0 
    libudunits2-dev 
    libcurl4-gnutls-dev 
    libssl-dev 
#    libhdf4-0 
#    libhdf4-dev 
    libhdf5-dev 
    gdal-bin libgdal-dev 
#    libgdal27 
    proj-bin libproj-dev 
#    libgdal-dev 
#    libgdal20 
    libgeos-dev 
    libnetcdf-dev
#    libproj-dev

## update system libraries
RUN apt-get update && 
    apt-get upgrade -y && 
    apt-get clean

# copy necessary files
## renv.lock file
COPY /tfwm-public-dashboard/renv.lock ./renv.lock

# install renv & restore packages
RUN Rscript -e 'install.packages("renv")'
RUN Rscript -e 'renv::restore()'

## app folder
COPY /tfwm-public-dashboard ./app

# expose port
EXPOSE 3838

# run app on container start
CMD ["R", "-e", "shiny::runApp('/tfwm-public-dashboard', host = '0.0.0.0', port = 3838)"]

I’ve commented out dependencies that conflicted when installed, or I added from other solutions and they appeared to have no effect on it.

The error I get after all the other r packages appear to load fine is:

Installing rgdal [1.3-6] ...
Error: install of package 'rgdal' failed
        FAILED
Error installing package 'rgdal':
=================================

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
** using staged installation
configure: R_HOME: /usr/local/lib/R
'config' variable 'CPP' is deprecated
configure: CC: gcc
configure: CXX: g++ -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.3-6
checking for /usr/bin/svnversion... no
configure: svn revision: 773
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.0.4
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
./configure: line 1979: ERROR:: command not found
./configure: line 1994: ERROR:: command not found
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/usr/local/lib/R/site-library/.renv/1/rgdal’
Traceback (most recent calls last):
14: renv::restore()
13: renv_restore_run_actions(project, diff, current, lockfile, rebuild)
12: renv_install(records, library)
11: renv_install_staged(records, library)
10: renv_install_default(records, library)
 9: handler(package, renv_install_impl(record))
 8: renv_install_impl(record)
 7: withCallingHandlers(renv_install_package_local(record), error = function(e) {
        vwritef("tFAILED")
        writef(e$output)
    })
 6: renv_install_package_local(record)
 5: renv_install_package_local_impl(package, path, library)
 4: r_cmd_install(package, path, library)
 3: r_exec(package, args, "install")
 2: r_exec_error(package, output, label)
 1: stop(error)
Execution halted
The command '/bin/sh -c Rscript -e 'renv::restore()'' returned a non-zero code: 1

I’ve looked at the other questions around this topic but they don’t seem to have the same error being thrown.

2

Answers


  1. Chosen as BEST ANSWER

    fixed it (kinda)

    by going through other versions of rocker Dockerfiles and building a composite, mostly stealing from geospatial. Here is the set up for the docker container that allows the rgdal installation.

    FROM rocker/shiny:3.6.3
    
    RUN apt-get update && apt-get install -y 
        lbzip2 
        libfftw3-dev 
        libgdal-dev 
        libgeos-dev 
        libgsl0-dev 
        libgl1-mesa-dev 
        libglu1-mesa-dev 
        libhdf4-alt-dev 
        libhdf5-dev 
        libjq-dev 
        liblwgeom-dev 
        libpq-dev 
        libproj-dev 
        libprotobuf-dev 
        libnetcdf-dev 
        libsqlite3-dev 
        libssl-dev 
        libudunits2-dev 
        netcdf-bin 
        postgis 
        protobuf-compiler 
        sqlite3 
        tk-dev 
        unixodbc-dev 
        libssh2-1-dev 
        r-cran-v8 
        libv8-dev 
        net-tools 
        libsqlite3-dev 
        libxml2-dev
    

  2. ./configure: line 1979: ERROR:: command not found
    ./configure: line 1994: ERROR:: command not found
    

    It’s hard to tell for sure, but based on that output + the associated configure script it seems like the C++ compiler is not being properly set or picked up:

    { $as_echo "$as_me:${as_lineno-$LINENO}: checking gdal: linking with --libs only" >&5
    $as_echo_n "checking gdal: linking with --libs only... " >&6; }
    ${CXX} ${CPPFLAGS} -o gdal_test gdal_test.cc ${LIBS} 2> errors.txt
    if test `echo $?` -ne 0 ; then
    gdalok=no
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
    $as_echo "no" >&6; }
    else
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
    $as_echo "yes" >&6; }
    fi
    
    if test "${gdalok}" = no; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking gdal: linking with --libs and --dep-libs" >&5
    $as_echo_n "checking gdal: linking with --libs and --dep-libs... " >&6; }
    LIBS="${LIBS} ${GDAL_DEP_LIBS}"
    gdalok=yes
    ${CXX} ${CPPFLAGS} -o gdal_test gdal_test.cc ${LIBS} 2>> errors.txt
    if test `echo $?` -ne 0 ; then
    gdalok=no
    fi
    if test "${gdalok}" = yes; then
        NEED_DEPS=yes
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
    $as_echo "yes" >&6; }
    else
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
    $as_echo "no" >&6; }
    fi
    fi
    

    My suspicion is that ${CXX} is empty for some reason. You might need to try installing or using a newer version of the rgdal package.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search