Rstudio shared library. R loads rgdal fine. Rstudio fails

docker
rstudioserver

#1

gdal loading error.
FIRST, IMPORTANT: Everything goes fine in R , not in Rstudio. Loading rgdal in R , works smoothly:

unable to load shared object ‘/opt/conda/lib/R/library/rgdal/libs/rgdal.so’:
/lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9’

library(rgdal)
Loading required package: sp
rgdal: version: 1.2-8, (SVN revision 663)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
Path to GDAL shared files: /opt/conda/share/gdal
Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
Path to PROJ.4 shared files: (autodetected)
Linking to sp version: 1.2-4
sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /opt/conda/lib/R/lib/libRblas.so
LAPACK: /opt/conda/lib/R/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] rgdal_1.2-8 sp_1.2-4

loaded via a namespace (and not attached):
[1] compiler_3.4.1 grid_3.4.1 lattice_0.20-34

Sys.getenv()
_ /opt/conda/bin/R
COLUMNS 184
CONDA_DIR /opt/conda
DEBIAN_FRONTEND noninteractive
EDITOR vi
HOME /home/jovyan
HOSTNAME 4512b594d7af
LANG en_US.UTF-8
LANGUAGE en_US.UTF-8
LC_ALL en_US.UTF-8
LINES 55
LN_S ln -s
LS_COLORS

MAKE make
MINICONDA_VERSION 4.3.30
NB_GID 100
NB_UID 1000
NB_USER jovyan
PAGER /usr/bin/less
PANDOC_TEMPLATES_VERSION
1.18
PASSWORD
PATH /usr/lib/rstudio-server/bin/:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD /
R_ARCH
R_BROWSER
R_BZIPCMD /opt/conda/bin/bzip2
R_DOC_DIR /opt/conda/lib/R/doc
R_GZIPCMD /usr/bin/gzip
R_HOME /opt/conda/lib/R
R_INCLUDE_DIR /opt/conda/lib/R/include
R_LIBS_SITE
R_LIBS_USER ~/R/x86_64-pc-linux-gnu-library/3.4
R_PAPERSIZE a4
R_PDFVIEWER
R_PLATFORM x86_64-pc-linux-gnu
R_PRINTCMD
R_RD4PDF times,inconsolata,hyper
R_SESSION_TMPDIR /tmp/RtmpvERdUC
R_SHARE_DIR /opt/conda/lib/R/share
R_SYSTEM_ABI linux,gcc,gxx,gfortran,?
R_TEXI2DVICMD texi2dvi
R_UNZIPCMD
R_ZIPCMD
SED /bin/sed
SHELL /bin/bash
SHLVL 1
TAR /bin/gtar
TERM xterm
USER vmasip

Not like rstudio:
library(rgdal)
Loading required package: sp
Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, …):
unable to load shared object ‘/opt/conda/lib/R/library/rgdal/libs/rgdal.so’:
/lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9’ not found (required by /opt/conda/lib/R/library/rgdal/libs/…/…/…/…/./libpng16.so.16)

sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /opt/conda/lib/R/lib/libRblas.so
LAPACK: /opt/conda/lib/R/lib/libRlapack.so

locale:
[1] LC_CTYPE=es_ES.UTF-8 LC_NUMERIC=C LC_TIME=es_ES.UTF-8 LC_COLLATE=es_ES.UTF-8
[5] LC_MONETARY=es_ES.UTF-8 LC_MESSAGES=es_ES.UTF-8 LC_PAPER=es_ES.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] sp_1.2-4

loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1 grid_3.4.1 lattice_0.20-34

Sys.getenv()
CLICOLOR_FORCE 1
DISPLAY :0
EDITOR vi
GIT_ASKPASS rpostback-askpass
HOME /home/vmasip
LANG es_ES.UTF-8
LD_LIBRARY_PATH /opt/conda/lib/R/lib:
LN_S ln -s
LOGNAME vmasip
MAKE make
PAGER /usr/bin/less
PATH /usr/bin:/usr/sbin:/bin:/sbin
R_BROWSER
R_BZIPCMD /opt/conda/bin/bzip2
R_DOC_DIR /opt/conda/lib/R/doc
R_GZIPCMD /usr/bin/gzip
R_HOME /opt/conda/lib/R
R_INCLUDE_DIR /opt/conda/lib/R/include
R_LIBS_SITE
R_LIBS_USER ~/R/x86_64-pc-linux-gnu-library/3.4
R_PAPERSIZE a4
R_PDFVIEWER
R_PLATFORM x86_64-pc-linux-gnu
R_PRINTCMD
R_RD4PDF times,inconsolata,hyper
R_SESSION_TMPDIR /tmp/RtmpRHVfDu
R_SHARE_DIR /opt/conda/lib/R/share
R_SYSTEM_ABI linux,gcc,gxx,gfortran,?
R_TEXI2DVICMD texi2dvi
R_UNZIPCMD
R_ZIPCMD
RMARKDOWN_MATHJAX_PATH /usr/lib/rstudio-server/resources/mathjax-26
RS_RPOSTBACK_PATH /usr/lib/rstudio-server/bin/rpostback
RSTUDIO 1
RSTUDIO_CONSOLE_COLOR 256
RSTUDIO_CONSOLE_WIDTH 121
RSTUDIO_HTTP_REFERER http://localhost:8787/
RSTUDIO_PANDOC /usr/lib/rstudio-server/bin/pandoc
RSTUDIO_SESSION_STREAM vmasip-d
RSTUDIO_USER_IDENTITY vmasip
RSTUDIO_WINUTILS bin/winutils
SED /bin/sed
SSH_ASKPASS rpostback-askpass
TAR /bin/gtar
TERM xterm-256color
USER vmasip

This is my conda list:

asn1crypto 0.22.0 py36_0 conda-forge
blas 1.1 openblas conda-forge
boost 1.65.1 py36_0 conda-forge
boost-cpp 1.65.1 1 conda-forge
bzip2 1.0.6 1 conda-forge
ca-certificates 2017.11.5 0 conda-forge
cairo 1.14.10 0 conda-forge
certifi 2017.11.5 py36_0 conda-forge
cffi 1.11.2 py36_0 conda-forge
chardet 3.0.4 py36_0 conda-forge
conda 4.3.29 py36_0 conda-forge
conda-env 2.6.0 0 conda-forge
cryptography 2.1.4 py36_0 conda-forge
curl 7.55.1 0 conda-forge
expat 2.2.5 0 conda-forge
fontconfig 2.12.6 0 conda-forge
freetype 2.8.1 0 conda-forge
freexl 1.0.4 0 conda-forge
geos 3.6.2 1 conda-forge
geotiff 1.4.2 1 conda-forge
gettext 0.19.7 1 conda-forge
giflib 5.1.4 0 conda-forge
glib 2.55.0 0 conda-forge
graphite2 1.3.10 0 conda-forge
gsl 2.2.1 blas_openblas_4 [blas_openblas] conda-forge
harfbuzz 1.7.1 0 conda-forge
hdf4 4.2.13 0 conda-forge
hdf5 1.10.1 1 conda-forge
icu 58.2 0 conda-forge
idna 2.6 py36_1 conda-forge
jpeg 9b 2 conda-forge
json-c 0.12.1 0 conda-forge
kealib 1.4.7 4 conda-forge
krb5 1.14.2 0 conda-forge
libdap4 3.18.3 2 conda-forge
libedit 3.1.20170329 0 conda-forge
libffi 3.2.1 3 conda-forge
libgcc 7.2.0 h69d50b8_2 defaults
libgcc-ng 7.2.0 h7cc24e2_2 defaults
libgdal 2.2.3 2 conda-forge
libgfortran 3.0.0 1 defaults
libiconv 1.15 0 conda-forge
libkml 1.3.0 5 conda-forge
libnetcdf 4.4.1.1 10 conda-forge
libpng 1.6.34 0 conda-forge
libpq 9.6.3 0 conda-forge
libspatialite 4.3.0a 19 conda-forge
libssh2 1.8.0 2 conda-forge
libstdcxx-ng 7.2.0 h7a57d05_2 defaults
libtiff 4.0.9 0 conda-forge
libxml2 2.9.7 0 conda-forge
ncurses 5.9 10 conda-forge
numpy 1.14.0 py36_blas_openblas_200 [blas_openblas] conda-forge
openblas 0.2.20 6 conda-forge
openjpeg 2.3.0 2 conda-forge
openssl 1.0.2n 0 conda-forge
pango 1.40.14 0 conda-forge
pcre 8.39 0 conda-forge
pip 9.0.1 py36_1 conda-forge
pixman 0.34.0 1 conda-forge
poppler 0.61.1 3 conda-forge
poppler-data 0.4.8 0 conda-forge
proj4 4.9.3 5 conda-forge
pycosat 0.6.3 py36_0 conda-forge
pycparser 2.18 py36_0 conda-forge
pyopenssl 17.4.0 py36_0 conda-forge
pysocks 1.6.7 py36_0 conda-forge
python 3.6.4 0 conda-forge
r-assertthat 0.1 r3.4.1_0 conda-forge
r-base 3.4.1 3 conda-forge
r-base64enc 0.1_3 r3.4.1_0 conda-forge
r-bh 1.65.0_1 r3.4.1_0 conda-forge
r-bindr 0.1 r3.4.1_0 conda-forge
r-bindrcpp 0.2 r3.4.1_0 conda-forge
r-bit 1.1_12 r3.4.1_0 conda-forge
r-bit64 0.9_5 r3.4.1_0 conda-forge
r-blob 1.1.0 r3.4.1_0 conda-forge
r-codetools 0.2_15 r3.4.1_0 conda-forge
r-colorspace 1.3_2 r3.4.1_0 conda-forge
r-crosstalk 1.0.0 r3.4.1_0 conda-forge
r-curl 2.4 r3.4.1_0 conda-forge
r-data.table 1.10.4 r3.4.1_0 conda-forge
r-dbi 0.6_1 r3.4.1_0 conda-forge
r-devtools 1.13.2 r3.4.1_0 conda-forge
r-dichromat 2.0_0 r3.4.1_0 conda-forge
r-digest 0.6.12 r3.4.1_0 conda-forge
r-domc 1.3.4 r3.4.1_0 conda-forge
r-dplyr 0.7.4 r3.4.1_0 conda-forge
r-foreach 1.4.3 r3.4.1_0 conda-forge
r-ggplot2 2.2.1 r3.4.1_0 conda-forge
r-git2r 0.19.0 r3.4.1_0 conda-forge
r-glue 1.1.1 r3.4.1_0 conda-forge
r-gridextra 2.3 r3.4.1_0 conda-forge
r-gtable 0.2.0 r3.4.1_0 conda-forge
r-hms 0.3 r3.4.1_0 conda-forge
r-htmltools 0.3.6 r3.4.1_0 conda-forge
r-htmlwidgets 0.9 r3.4.1_0 conda-forge
r-httpuv 1.3.3 r3.4.1_0 conda-forge
r-httr 1.2.1 r3.4.1_0 conda-forge
r-iterators 1.0.8 r3.4.1_0 conda-forge
r-jsonlite 1.4 r3.4.1_0 conda-forge
r-labeling 0.3 r3.4.1_0 conda-forge
r-lattice 0.20_34 r3.4.1_0 conda-forge
r-lazyeval 0.2.0 r3.4.1_0 conda-forge
r-leaflet 1.1.0 r3.4.1_0 conda-forge
r-magrittr 1.5 r3.4.1_0 conda-forge
r-markdown 0.8 r3.4.1_0 conda-forge
r-mass 7.3_45 r3.4.1_0 conda-forge
r-memoise 1.1.0 r3.4.1_0 conda-forge
r-mime 0.5 r3.4.1_0 conda-forge
r-munsell 0.4.3 r3.4.1_0 conda-forge
r-openssl 0.9.7 r3.4.1_0 conda-forge
r-pkgconfig 2.0.1 r3.4.1_0 conda-forge
r-plogr 0.1_1 r3.4.1_0 conda-forge
r-plyr 1.8.4 r3.4.1_0 conda-forge
r-png 0.1_7 r3.4.1_0 conda-forge
r-r6 2.2.0 r3.4.1_0 conda-forge
r-raster 2.5_8 r3.4.1_0 conda-forge
r-rcolorbrewer 1.1_2 r3.4.1_0 conda-forge
r-rcpp 0.12.13 r3.4.1_0 conda-forge
r-readr 1.1.0 r3.4.1_0 conda-forge
r-reshape2 1.4.2 r3.4.1_0 conda-forge
r-rgdal 1.2_8 r3.4.1_2 conda-forge
r-rlang 0.1.2 r3.4.1_0 conda-forge
r-rsqlite 2.0 r3.4.1_0 conda-forge
r-rstudioapi 0.7 r3.4.1_0 conda-forge
r-scales 0.4.1 r3.4.1_0 conda-forge
r-shiny 1.0.3 r3.4.1_0 conda-forge
r-sourcetools 0.1.6 r3.4.1_0 conda-forge
r-sp 1.2_4 r3.4.1_0 conda-forge
r-stringi 1.1.2 r3.4.1_0 conda-forge
r-stringr 1.2.0 r3.4.1_0 conda-forge
r-tibble 1.3.3 r3.4.1_0 conda-forge
r-viridis 0.4.0 r3.4.1_0 conda-forge
r-viridislite 0.2.0 r3.4.1_0 conda-forge
r-whisker 0.3_2 r3.4.1_0 conda-forge
r-withr 1.0.2 r3.4.1_0 conda-forge
r-xtable 1.8_2 r3.4.1_0 conda-forge
r-yaml 2.1.14 r3.4.1_0 conda-forge
readline 7.0 0 conda-forge
requests 2.18.4 py36_1 conda-forge
ruamel_yaml 0.11.14 py36_0 conda-forge
setuptools 38.4.0 py36_0 conda-forge
six 1.11.0 py36_1 conda-forge
sqlite 3.20.1 2 conda-forge
tk 8.6.7 0 conda-forge
urllib3 1.22 py36_0 conda-forge
util-linux 2.21 0 defaults
wheel 0.30.0 py36_2 conda-forge
xerces-c 3.2.0 0 conda-forge
xz 5.2.3 0 conda-forge
yaml 0.1.6 0 conda-forge
zlib 1.2.11 0 conda-forge

I’ve tried changing from rstudio enviroment variables - Sys.setenv(…) but still not working. Older versions of r-rgdal fails in R too.


#2

I may not have the exact answer to your question. But when I had a similar error related to zlib_.1.2.9 in another context, making LD_LIBRARY_PATH include path to the anaconda lib directory helped. Also to set that LD_LIBRARY_PATH, the Sys.setenv did not work. I did it from linux command line in the following way:

sudo /bin/bash -c "echo ‘rsession-ld-library-path=“pathname”’ >> /etc/rstudio/rserver.conf"
sudo rstudio-server restart