Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to load shared object '/opt/conda/lib/R/library/sf/libs/sf.so #94

Closed
btupper opened this issue Aug 15, 2022 · 19 comments · Fixed by oceanhackweek/jupyter-image#57

Comments

@btupper
Copy link
Contributor

btupper commented Aug 15, 2022

Hi,

Hmmm. Perhaps a path issue?

library(xyzt)
library(sf)

x <- xyzt::read_calcofi()

x <- sf::st_as_sf(x, coords = c("lon", "lat"),
                  dim = 'XY', crs = 4326)

#Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...):
# unable to load shared object '/opt/conda/lib/R/library/sf/libs/sf.so':
#  /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/lib/R/library/sf/libs/../../../../libgdal.so.31)

# > traceback()
# 10: stop(msg, call. = FALSE, domain = NA)
# 9: value[[3L]](cond)
# 8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
# 7: tryCatchList(expr, classes, parentenv, handlers)
# 6: tryCatch({
#   attr(package, "LibPath") <- which.lib.loc
#   ns <- loadNamespace(package, lib.loc)
#   env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)
# }, error = function(e) {
#   P <- if (!is.null(cc <- conditionCall(e))) 
#     paste(" in", deparse(cc)[1L])
#   else ""
#   msg <- gettextf("package or namespace load failed for %s%s:\n %s", 
#                   sQuote(package), P, conditionMessage(e))
#   if (logical.return && !quietly) 
#     message(paste("Error:", msg), domain = NA)
#   else stop(msg, call. = FALSE, domain = NA)
# })
# 5: library(sf) at .active-rstudio-document#2
# 4: eval(ei, envir)
# 3: eval(ei, envir)
# 2: withVisible(eval(ei, envir))
# 1: source("~/.active-rstudio-document")
# > sessionInfo()
# R version 4.1.3 (2022-03-10)
# Platform: x86_64-conda-linux-gnu (64-bit)
# Running under: Debian GNU/Linux 11 (bullseye)
# 
# Matrix products: default
# BLAS/LAPACK: /opt/conda/lib/libopenblasp-r0.3.21.so
# 
# locale:
#   [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8    
# [5] LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C             
# [9] LC_ADDRESS=C           LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
# 
# attached base packages:
#   [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
#   [1] xyzt_0.1
# 
# loaded via a namespace (and not attached):
#   [1] Rcpp_1.0.9         rstudioapi_0.13    magrittr_2.0.3     units_0.8-0        tidyselect_1.1.2  
# [6] R6_2.5.1           rlang_1.0.4        fansi_1.0.3        dplyr_1.0.9        tools_4.1.3       
# [11] ghrsst_0.1         grid_4.1.3         KernSmooth_2.23-20 utf8_1.2.2         cli_3.3.0         
# [16] e1071_1.7-11       DBI_1.1.3          class_7.3-20       assertthat_0.2.1   tibble_3.1.8      
# [21] lifecycle_1.0.1    purrr_0.3.4        vctrs_0.4.1        ncdf4_1.19         glue_1.6.2        
# [26] proxy_0.4-27       compiler_4.1.3     pillar_1.8.0       generics_0.1.3     classInt_0.4-7    
# [31] pkgconfig_2.0.3 
  
@abkfenris
Copy link
Contributor

@ocefpaf Is it me or does it look like it's yelling about missing a specific version of libc?

@btupper
Copy link
Contributor Author

btupper commented Aug 15, 2022

I just noticed a warning that appears when the markdown is rendered, but doesn't appear when the same commands (above) are run at the R prompt. I have pasted it in below. It points to proj as an issue.

The markdown actually does render successfully, but coordinate reference system are absent (which is possible in sf).

x <- xyzt::read_calcofi()

x <- sf::st_as_sf(x, coords = c("lon", "lat"),
                  dim = 'XY', crs = 4326)

## Warning in CPL_crs_from_input(x): GDAL Error 1: PROJ: proj_create_from_database:
## Open of /opt/conda/share/proj failed

@ocefpaf
Copy link
Member

ocefpaf commented Aug 15, 2022

@ocefpaf Is it me or does it look like it's yelling about missing a specific version of libc?

@abkfenris looks like our Python image is OK b/c we can not run an older glibc on a newer they are all forward compatible. (The opposite is not true though.)

Screenshot from 2022-08-15 13-14-52

Could this be related to RStudio? After I chose the Python image on the hub I'm having issue to switch to the RStudio one, so I cannot test this there at the moment.

@abkfenris
Copy link
Contributor

https://oceanhackweek.2i2c.cloud/hub/home to stop your server and switch to the R profile

@abkfenris
Copy link
Contributor

In the R profile

(base) jovyan@jupyter-abkfenris:~$ /sbin/ldconfig -p | grep stdc++
        libstdc++.so.6 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
        libstdc++.so.6 (libc6) => /usr/lib32/libstdc++.so.6
(base) jovyan@jupyter-abkfenris:~$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep LIBCXX
bash: strings: command not found

@ocefpaf
Copy link
Member

ocefpaf commented Aug 15, 2022

Yep. Just did that and....

 /sbin/ldconfig -p | grep stdc++        libstdc++.so.6 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
        libstdc++.so.6 (libc6) => /usr/lib32/libstdc++.so.6

I'm not sure there are two. The images are not based on the same base are they? The strings command is not available to explore more. Looking into it...

@ocefpaf
Copy link
Member

ocefpaf commented Aug 15, 2022

@btupper I'm not familiar with R packaging but could any of the dependencies we are installing bring a pre-compiled binary? Could that be the culprit?


Probably not. All the GitHub installs are using dependencies=FALSE, upgrade_dependencies=FALSE, upgrade=FALSE.

@ocefpaf
Copy link
Member

ocefpaf commented Aug 15, 2022

Hmmm. Perhaps a path issue?

Most likely. I just tried the RStudio console and it breaks as you reported:

Screenshot from 2022-08-15 14-10-46

But if I open a terminal, then R, then try that code, everything works:

Screenshot from 2022-08-15 14-10-36

Not sure how to change the lookup path for RStudio, or how it would break if we do so!

@btupper
Copy link
Contributor Author

btupper commented Aug 15, 2022

RStudio -> markdown rendering: throws error as shown above
RStudio -> console: throws warning abut proj, not an error, CRS lost
RStudio -> Terminal: now error, no warning, CRS preserved - all good!

R console (via jupyter-hub/lab): throws proj warning, complains of missing geojsonio package

@ocefpaf
Copy link
Member

ocefpaf commented Aug 15, 2022

oceanhackweek/jupyter-image#57 kind of works for me. The proj data still requires user to do Sys.setenv(PROJ_LIB="/opt/conda/share/proj") before running but at least the code above works as expected.

Screenshot from 2022-08-15 18-31-07

@abkfenris
Copy link
Contributor

RStudio seems to be coming up it's own environment.

> Sys.getenv()
CLICOLOR_FORCE             1
DISPLAY                    :0
EDITOR                     vi
GIT_ASKPASS                rpostback-askpass
HOME                       /home/jovyan
LANG                       C.UTF-8
LD_LIBRARY_PATH            /opt/conda/lib/R/lib:/opt/conda/lib:/opt/conda/lib
LN_S                       ln -s
LOGNAME                    jovyan
MAKE                       make
MPLENGINE                  tkAgg
PAGER                      less
PATH                       /usr/lib/rstudio-server/bin/:/opt/conda/lib/R/library/littler/bin:/opt/conda/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/rstudio-server/bin/quarto/bin:/usr/lib/rstudio-server/bin/postback:/usr/lib/rstudio-server/bin/postback
R_BROWSER                  
R_BZIPCMD                  /opt/conda/bin/bzip2
R_CLI_HAS_HYPERLINK_IDE_HELP
                           true
R_CLI_HAS_HYPERLINK_IDE_RUN
                           true
R_CLI_HAS_HYPERLINK_IDE_VIGNETTE
                           true
R_DOC_DIR                  /opt/conda/lib/R/doc
R_GZIPCMD                  gzip
R_HOME                     /opt/conda/lib/R
R_INCLUDE_DIR              /opt/conda/lib/R/include
R_LIBS_SITE                
R_LIBS_USER                ~/R/x86_64-conda-linux-gnu-library/4.1
R_PAPERSIZE                a4
R_PDFVIEWER                
R_PLATFORM                 x86_64-conda-linux-gnu
R_PRINTCMD                 
R_RD4PDF                   times,inconsolata,hyper
R_SESSION_TMPDIR           /tmp/RtmpAaZMU4
R_SHARE_DIR                /opt/conda/lib/R/share
R_STRIP_SHARED_LIB         x86_64-conda-linux-gnu-strip --strip-unneeded
R_STRIP_STATIC_LIB         x86_64-conda-linux-gnu-strip --strip-debug
R_SYSTEM_ABI               linux,gcc,gxx,gfortran,gfortran
R_TEXI2DVICMD              /home/conda/feedstock_root/build_artifacts/r-base-split_1660164760553/_build_env/bin/texi2dvi
R_UNZIPCMD                 
R_ZIPCMD                   
RMARKDOWN_MATHJAX_PATH     /usr/lib/rstudio-server/resources/mathjax-27
RS_RPOSTBACK_PATH          /usr/lib/rstudio-server/bin/rpostback
RS_SERVER_RPC_SOCKET_PATH
                           /var/run/rstudio-server/rstudio-rserver/session-server-rpc.socket
RS_SESSION_TMP_DIR         /var/run/rstudio-server/rstudio-rsession
RSTUDIO                    1
RSTUDIO_CLI_HYPERLINKS     true
RSTUDIO_CONSOLE_COLOR      256
RSTUDIO_CONSOLE_WIDTH      93
RSTUDIO_HTTP_REFERER       http://127.0.0.1:8080/rstudio/
RSTUDIO_PANDOC             /usr/lib/rstudio-server/bin/quarto/bin/tools
RSTUDIO_PROGRAM_MODE       server
RSTUDIO_R_MODULE           
RSTUDIO_R_PRELAUNCH_SCRIPT
                           
RSTUDIO_R_REPO             
RSTUDIO_R_VERSION_LABEL    
RSTUDIO_SESSION_PID        75
RSTUDIO_SESSION_STREAM     jovyan-d
RSTUDIO_USER_IDENTITY      jovyan
RSTUDIO_USER_IDENTITY_DISPLAY
                           jovyan
RSTUDIO_WINUTILS           bin/winutils
SED                        /opt/conda/bin/sed
SSH_ASKPASS                rpostback-askpass
TAR                        tar
TERM                       xterm-256color
USER                       jovyan
(base) $ env
CONDA_PROMPT_MODIFIER=(base) 
CONDA_ENV=base
JUPYTER_SERVER_ROOT=/home/jovyan
HOSTNAME=b0207e79e72e
LD_LIBRARY_PATH=/opt/conda/lib
HOME=/home/jovyan
CONDA_SHLVL=1
UDUNITS2_XML_PATH=/opt/conda/share/udunits/udunits2.xml
PYTHONUNBUFFERED=1
CPL_ZIP_ENCODING=UTF-8
NB_USER=jovyan
_CE_M=
RSTUDIO_WHICH_R=/opt/conda/bin/R
PYXTERM_DIMENSIONS=80x25
PYTHONDONTWRITEBYTECODE=1
R_LIBS_USER=/opt/r
TERM=xterm-256color
COLUMNS=80
_CE_CONDA=
RSTUDIO_URL=https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2022.07.1-554-amd64.deb
_CONDA_SET_PROJ_LIB=/opt/conda/share/proj
PATH=/opt/conda/bin:/opt/conda/condabin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
PROJ_NETWORK=ON
LANG=C.UTF-8
CONDA_PYTHON_EXE=/opt/conda/bin/python
GSETTINGS_SCHEMA_DIR=/opt/conda/share/glib-2.0/schemas
GDAL_DRIVER_PATH=/opt/conda/lib/gdalplugins
CONDA_DEFAULT_ENV=base
CONDA_DIR=/opt/conda
LC_ALL=C.UTF-8
PROJ_LIB=/opt/conda/share/proj
PWD=/home/jovyan
CONDA_EXE=/opt/conda/bin/conda
PYDEVD_USE_FRAME_EVAL=NO
LINES=25
NB_UID=1000
CONDA_PREFIX=/opt/conda
GSETTINGS_SCHEMA_DIR_CONDA_BACKUP=
GDAL_DATA=/opt/conda/share/gdal
JUPYTER_SERVER_URL=http://b0207e79e72e:8080/

@jevanilla
Copy link
Contributor

@ocefpaf I'm still getting this error in the RStudio instance on the hub:

Sys.setenv(PROJ_LIB="/opt/conda/share/proj")
library(sf)

Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/opt/conda/lib/R/library/sf/libs/sf.so': /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/lib/R/library/sf/libs/../../../../libgdal.so.31)

@abkfenris
Copy link
Contributor

These changes haven't gone live yet. The image hasn't even finished building! https://github.com/oceanhackweek/jupyter-image/runs/7860496038?check_suite_focus=true

@abkfenris
Copy link
Contributor

Ok, the image is built, but we need to wait for 2i2c to approve and merge the new image: 2i2c-org/infrastructure#1631

@abkfenris
Copy link
Contributor

Now for 2i2c's deployment, then you can shut down and restart your profile to test https://github.com/2i2c-org/infrastructure/actions/runs/2869052365

@abkfenris
Copy link
Contributor

Now it's yelling about being linked to the wrong GDAL GEOS linking again

@abkfenris
Copy link
Contributor

Waiting on a new PR to be merged: 2i2c-org/infrastructure#1632 that will hopefully get us down to just warnings after adding a Rprofile.site in oceanhackweek/jupyter-image#59

@btupper
Copy link
Contributor Author

btupper commented Aug 16, 2022

Sweet - my thanks to you and @ocefpaf for lifting us over this bump!

@abkfenris
Copy link
Contributor

We still get the warnings about GEOS, but at least proj is playing nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants