rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
1.02k stars 155 forks source link

renv doesnt use vendored GLPK from igraph #1881

Closed AmelZulji closed 5 months ago

AmelZulji commented 6 months ago

Hello there,

On this system:

NAME="Red Hat Enterprise Linux"
VERSION="8.8 (Ootpa)"

During renv::install("igraph") i get following error:

# Installing packages --------------------------------------------------------
- Installing igraph ...                         FAILED
/gpfs/bwfor/software/common/math/R/4.3.3-mkl-2022.2-gnu-12.1/lib64/R/bin/R --vanilla -s -f '/gpfs/bwfor/scratch/hd_ut239_o05i14/RtmpLa30XJ/renv-install-252de6f08a42b.R'
================================================================================

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/gpfs/bwfor/home/hd/hd_hd/hd_ut239/test_renv/renv/staging/1/igraph/libs/igraph.so':
  libglpk.so.40: cannot open shared object file: No such file or directory
Calls: loadNamespace -> library.dynam -> dyn.load
Execution halted

Error: error testing if 'igraph' can be loaded [error code 1]
Traceback (most recent calls last):
13: renv::install("igraph")
12: renv_install_impl(records)
11: renv_install_staged(records)
10: renv_install_default(records)
 9: handler(package, renv_install_package(record))
 8: renv_install_package(record)
 7: withCallingHandlers(renv_install_package_impl(record), error = function(e) writef("FAILED"))
 6: renv_install_package_impl(record)
 5: withCallingHandlers(if (isbin) renv_install_test(package), error = function(err) unlink(installpath, 
        recursive = TRUE))
 4: renv_install_test(package)
 3: renv_system_exec(command = R(), args = c("--vanilla", "-s", "-f", 
        renv_shell_path(script)), action = sprintf("testing if '%s' can be loaded", 
        package))
 2: abort(sprintf("error %s [error code %i]", action, status), body = renv_system_exec_details(command, 
        args, output))
 1: stop(fallback)

I understand it has to do with missing libglpk. However, utils::install.packages("igraph") is able to install (it shows that it is using vendored GLPK). Is it possible to do it with renv as well?

I have no root, and installing libglpk might not be possible ...

Thank you and regards, Amel

GischD commented 6 months ago

Hey @AmelZulji and renv team.

I got the same issue.

/usr/lib/R/bin/R --vanilla -s -f '/tmp/RtmprJDEmj/renv-install-12c9222da6cd1.R'

Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/home/dlg/Documents/mes_cells/ren_toadata/renv/staging/1/igraph/libs/igraph.so': libglpk.so.40: cannot open shared object file: No such file or directory Calls: loadNamespace -> library.dynam -> dyn.load Execution halted

Error: error testing if 'igraph' can be loaded [error code 1] Traceback (most recent calls last): 13: renv::install("Seurat") 12: renv_install_impl(records) 11: renv_install_staged(records) 10: renv_install_default(records) 9: handler(package, renv_install_package(record)) 8: renv_install_package(record) 7: withCallingHandlers(renv_install_package_impl(record), error = function(e) writef("FAILED")) 6: renv_install_package_impl(record) 5: withCallingHandlers(if (isbin) renv_install_test(package), error = function(err) unlink(installpath, recursive = TRUE)) 4: renv_install_test(package) 3: renv_system_exec(command = R(), args = c("--vanilla", "-s", "-f", renv_shell_path(script)), action = sprintf("testing if '%s' can be loaded", package)) 2: abort(sprintf("error %s [error code %i]", action, status), body = renv_system_exec_details(command, args, output)) 1: stop(fallback)

Thanks, Debora

kevinushey commented 6 months ago

Can you please share the output of:

renv::install("igraph", verbose = TRUE, rebuild = TRUE)

The installation log is unfortunately not displayed by default if a failure occurs when loading a package (I should change that). Mainly, I want to confirm whether renv appears to be using a system-installed GLPK, or the vendored GLPK, when installing the package.

kevinushey commented 6 months ago

Actually... I wonder if the issue here is that you're installing a package binary (e.g. from Posit Package Manager), but that binary isn't compatible with your RHEL system?

The output of renv::diagnostics() may be useful.

AmelZulji commented 6 months ago

Thank you for looking into this, Kevin!

here is output of renv::install("igraph", verbose = TRUE, rebuild = TRUE):

Error: package or namespace load failed for 'igraph' in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object 'projects/test_renv_compilation/renv/staging/1/00LOCK-igraph/00new/igraph/libs/igraph.so':
  libicui18n.so.73: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing 'projects/test_renv_compilation/renv/staging/1/igraph'
FAILED
Error: install of package 'igraph' failed
Traceback (most recent calls last):
11: renv::install("igraph", rebuild = T, verbose = T)
10: renv_install_impl(records)
 9: renv_install_staged(records)
 8: renv_install_default(records)
 7: handler(package, renv_install_package(record))
 6: renv_install_package(record)
 5: withCallingHandlers(renv_install_package_impl(record), error = function(e) writef("FAILED"))
 4: renv_install_package_impl(record)
 3: r_cmd_install(package, path)
 2: stopf("install of package '%s' failed", package)
 1: stop(sprintf(fmt, ...), call. = call.)

here is the output of :

> renv::diagnostics()
Diagnostics Report [renv 1.0.7]
===============================

# Session Info ---------------------------------------------------------------
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.8 (Ootpa)

Matrix products: default
BLAS/LAPACK: software/common/compiler/intel/2022.2/mkl/2022.1.0/lib/intel64/libmkl_gf_lp64.so.2

locale:
 [1] LC_CTYPE=C                 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 datasets  utils     methods   base

loaded via a namespace (and not attached):
[1] compiler_4.2.1 tools_4.2.1    renv_1.0.7

# Project --------------------------------------------------------------------
Project path: "projects/test_renv_compilation"

# Status ---------------------------------------------------------------------
No issues found -- the project is in a consistent state.

# Packages -------------------------------------------------------------------
           Library Source Lockfile Source Path Dependency
KernSmooth 2.23-20   CRAN     <NA>   <NA>  [2]       <NA>
MASS        7.3-57   CRAN     <NA>   <NA>  [2]       <NA>
Matrix       1.4-1   CRAN     <NA>   <NA>  [2]       <NA>
boot        1.3-28   CRAN     <NA>   <NA>  [2]       <NA>
class       7.3-20   CRAN     <NA>   <NA>  [2]       <NA>
cluster      2.1.3   CRAN     <NA>   <NA>  [2]       <NA>
codetools   0.2-18   CRAN     <NA>   <NA>  [2]       <NA>
foreign     0.8-82   CRAN     <NA>   <NA>  [2]       <NA>
lattice    0.20-45   CRAN     <NA>   <NA>  [2]       <NA>
mgcv        1.8-40   CRAN     <NA>   <NA>  [2]       <NA>
nlme       3.1-157   CRAN     <NA>   <NA>  [2]       <NA>
nnet        7.3-17   CRAN     <NA>   <NA>  [2]       <NA>
renv         1.0.7   CRAN    1.0.7   CRAN  [1]     direct
rpart       4.1.16   CRAN     <NA>   <NA>  [2]       <NA>
spatial     7.3-15   CRAN     <NA>   <NA>  [2]       <NA>
survival     3.3-1   CRAN     <NA>   <NA>  [2]       <NA>
utils         <NA>   <NA>     <NA>   <NA>  [2]   indirect

[1]: projects/test_renv_compilation/renv/library/R-4.2/x86_64-pc-linux-gnu
[2]: .cache/R/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/225893a6

# ABI ------------------------------------------------------------------------
- No ABI problems were detected in the set of installed packages.

# User Profile ---------------------------------------------------------------
[no user profile detected]

# Settings -------------------------------------------------------------------
List of 13
 $ bioconductor.version     : NULL
 $ external.libraries       : chr(0)
 $ ignored.packages         : chr(0)
 $ package.dependency.fields: chr [1:3] "Imports" "Depends" "LinkingTo"
 $ ppm.enabled              : NULL
 $ ppm.ignored.urls         : chr(0)
 $ r.version                : NULL
 $ snapshot.type            : chr "implicit"
 $ use.cache                : logi TRUE
 $ vcs.ignore.cellar        : logi TRUE
 $ vcs.ignore.library       : logi TRUE
 $ vcs.ignore.local         : logi TRUE
 $ vcs.manage.ignores       : logi TRUE

# Options --------------------------------------------------------------------
List of 8
 $ defaultPackages                     : chr [1:6] "datasets" "utils" "grDevices" "graphics" ...
 $ download.file.method                : NULL
 $ download.file.extra                 : NULL
 $ install.packages.compile.from.source: NULL
 $ pkgType                             : chr "source"
 $ repos                               : Named chr "https://cloud.r-project.org"
  ..- attr(*, "names")= chr "CRAN"
 $ renv.consent                        : logi TRUE
 $ renv.verbose                        : logi TRUE

# Environment Variables ------------------------------------------------------
HOME                        = /home/hd/hd_hd/hd_ut239
LANG                        = en_US.UTF-8
MAKE                        = make
R_LIBS                      = <NA>
R_LIBS_SITE                 = common/math/R/4.2.1-mkl-2022.2-gnu-12.1-cairo/lib64/R/site-library
R_LIBS_USER                 = projects/test_renv_compilation/renv/library/R-4.2/x86_64-pc-linux-gnu
RENV_DEFAULT_R_ENVIRON      = <NA>
RENV_DEFAULT_R_ENVIRON_USER = <NA>
RENV_DEFAULT_R_LIBS         = <NA>
RENV_DEFAULT_R_LIBS_SITE    = common/math/R/4.2.1-mkl-2022.2-gnu-12.1-cairo/lib64/R/site-library
RENV_DEFAULT_R_LIBS_USER    = R/x86_64-pc-linux-gnu-library/4.2
RENV_DEFAULT_R_PROFILE      = <NA>
RENV_DEFAULT_R_PROFILE_USER = <NA>
RENV_PROJECT                = projects/test_renv_compilation

# PATH -----------------------------------------------------------------------
- common/lib/hdf5/1.12.2-gnu-12.1/bin
- common/compiler/gnu/12.1.0/bin
- common/math/R/4.2.1-mkl-2022.2-gnu-12.1-cairo/bin
- common/devel/miniconda/3-py39-23.10.0/bin
- common/devel/miniconda/3-py39-23.10.0/condabin
- .local/bin
- /bin
- /usr/local/bin
- /usr/bin
- /usr/local/sbin
- /usr/sbin
- /bin/cmake-3.25.2-linux-x86_64/bin

# Cache ----------------------------------------------------------------------
There are a total of 247 packages installed in the renv cache.
Cache path: "/R/renv/cache/v5/R-4.2/x86_64-pc-linux-gnu"

Interestingly, when the installation succeeds with utils::install.package(), the error appears when i try to load the library in Rstudio. To further test it I installed locally GLPK and if I dyn.load()in Rstudio the missing shared object, then I can load the library installed with utils::install.package(). However, if i try to install the package with either renv or utils (by providing local GLPK on path via export LD_LBRARY_PATH) it fails in both cases (and I know that the local GLPK is properly reconized because at the begning of the installation it says using installed GLPK as compared to instllation without it when it says using vendored GLPK).

I am completely confused. Do you have any resource to suggest to further read in general about renv, R and R package managment. After this, I think I have no clear idea as to how .Renviron, .Rprofile behave. I have an impression that sometimes some variables are kind of declared but not properly used (I cant clearly articulate the confusion...)

Thank you again for looking into this. Regards, Amel

AmelZulji commented 6 months ago

P.S. I removed parts of the PATHs which might be sensitive. Let me know if full PATHs are needed.

szhorvat commented 6 months ago
  • common/devel/miniconda/3-py39-23.10.0/bin
  • common/devel/miniconda/3-py39-23.10.0/condabin

igraph maintainer here. We strongly recommend to disable any conda environments before compiling igraph. See https://r.igraph.org/articles/installation-troubleshooting.html

Typically what happens is that the build system picks up libraries from within the conda environment. Then when you either update packages in that environment, or disable it, the libraries are no longer found. Anaconda themselves recommend not to have conda's bin directory in the path by default.

While this may not be the only issue here, the path to debugging would be to (1) disable all environment before compiling igraph (2) try in an R session in a terminal, without any IDEs (RStudio or other).

AmelZulji commented 6 months ago

Hi @szhorvat

I can confirm that:

  1. there was no active conda environment during installation
  2. Installation was attempted from R terminal not IDE

My feeling is that LD_LIBRARY_PATH is problematic here (i.e. R doesnt properly inherit it when launched)...

szhorvat commented 6 months ago

there was no active conda environment during installation

To be more specific, can you also confirm that conda's bin directory was not in your path?

This should not be in your path:

  • common/devel/miniconda/3-py39-23.10.0/bin

This is fine (and necessary for conda to work):

  • common/devel/miniconda/3-py39-23.10.0/condabin
szhorvat commented 6 months ago

My feeling is that LD_LIBRARY_PATH is problematic here (i.e. R doesnt properly inherit it when launched)...

That is possible. Do you have the libraries in a non-standard location? Can you check which specific libraries igraph.so is linking to?

AmelZulji commented 5 months ago

To be more specific, can you also confirm that conda's bin directory was not in your path?

yes, I can confirm that as well.

kevinushey commented 5 months ago

In case renv is trying to install a binary from PPM, you could also try this following:

renv::settings$ppm.enabled(FALSE)
renv::install("igraph", type = "source", rebuild = TRUE)
AmelZulji commented 5 months ago

Thank you for for checking this, @kevinushey and @szhorvat, I can confirm that this is related to internal R issue. Namely R is available as module and when it is loaded for some reason LD_LIBRARY_PATH is incorect. Setting proper LD_LIBRARY_PATH in .Renviron solved the issue.