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

Problem with shared object libraries #2

Open
ctroupin opened this issue Feb 23, 2024 · 3 comments
Open

Problem with shared object libraries #2

ctroupin opened this issue Feb 23, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@ctroupin
Copy link
Member

Summary

We experience issues due to different versions of the shared libraries. One setting allows one to work with DIVAnd, while other R libraries fail. The other setting allows the opposite.

How to reproduce?

Setting 1

  • Install Julia: curl -fsSL https://install.julialang.org | sh
  • Execute the following commands in R:
install.packages("JuliaCall")
library(JuliaCall)
julia_setup(JULIA_HOME = path.expand("~/.juliaup/bin/"))
julia_install_package_if_needed("DIVAnd")
julia_command("using DIVAnd")

The last command should give an error:

Error: Error happens in Julia.
InitError: could not load symbol "nc_inq_libvers":
/usr/lib/R/bin/exec/R: undefined symbol: nc_inq_libvers
Stacktrace:
  [1] nc_inq_libvers
    @ ~/.julia/packages/NCDatasets/lc5lk/src/netcdf_c.jl:242 [inlined]
  [2] netcdf_version()
    @ NCDatasets ~/.julia/packages/NCDatasets/lc5lk/src/netcdf_c.jl:2170
  [3] init_certificate_authority()
    @ NCDatasets ~/.julia/packages/NCDatasets/lc5lk/src/netcdf_c.jl:2183
  [4] __init__()
    @ NCDatasets ~/.julia/packages/NCDatasets/lc5lk/src/NCDatasets.jl:46
  [5] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1134
  [6] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1122
  [7] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1067
  [8] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::String, sourcepath::String, depmods::Vector{Any})
    @ Base .

Setting 2

Before starting the R session we set the environment variable:

export LD_PRELOAD=${HOME}/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/lib/julia/libcurl.so.4.8.0`

The previous commands should not work:

install.packages("JuliaCall")
library(JuliaCall)
julia_setup(JULIA_HOME = path.expand("~/.juliaup/bin/"))
julia_install_package_if_needed("DIVAnd")
julia_command("using DIVAnd")

Issue

Now we can try to load another library, for example ncdf4

> library("ncdf4")
Error: package or namespace load failed forncdf4in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/ctroupin/R/x86_64-pc-linux-gnu-library/4.3/ncdf4/libs/ncdf4.so':
  /home/ctroupin/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/lib/julia/libcurl.so.4.8.0: version `CURL_OPENSSL_4' not found (required by /usr/lib/x86_64-linux-gnu/libnetcdf.so.19)
``
@ctroupin ctroupin added the bug Something isn't working label Feb 23, 2024
@ctroupin ctroupin self-assigned this Feb 23, 2024
@maelle
Copy link

maelle commented Mar 4, 2024

just in case you don't know about callr, for when you want to call R in different sessions (from what I understood): https://callr.r-lib.org/

@ctroupin
Copy link
Member Author

ctroupin commented Mar 4, 2024

Thanks Maelle, I didn't know about the package, I will test that soon!

@ctroupin
Copy link
Member Author

ctroupin commented Mar 11, 2024

Testing under Windows by a colleague:

  • R version 4.2.2
  • Julia 1.10.1+0.x64.w64.mingw32.

Installation of JuliaCall

> install.packages("JuliaCall")
Installing package intoC:/Users/Administrator/AppData/Local/R/win-library/4.2’
(aslibis unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/JuliaCall_0.17.5.zip'
Content type 'application/zip' length 1264289 bytes (1.2 MB)
downloaded 1.2 MB

packageJuliaCallsuccessfully unpacked and MD5 sums checked

The downloaded binary packages are in
        C:\Users\Administrator\AppData\Local\Temp\RtmpuSmFVL\downloaded_packages

Importing JuliaCall library

> library(JuliaCall)
Warning message:
packageJuliaCallwas built under R version 4.2.3
> julia_setup(JULIA_HOME = path.expand("~/.juliaup/bin/"))
Error in julia_setup(JULIA_HOME = path.expand("~/.juliaup/bin/")) :
  Julia is not found.

Failure due to the Julia path not specified.

Importing JuliaCall after specifying Julia path

Seems to work without any issue.

> julia_setup(JULIA_HOME = "C:/Users/Administrator/.julia/juliaup/julia-1.10.1+0.x64.w64.mingw32/bin")
Julia version 1.10.1 at location C:\Users\ADMINI~1\JULIA~1\juliaup\JULIA-~1.MIN\bin will be used.
Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.
> julia_install_package_if_needed("DIVAnd")
NULL
> julia_install_package_if_needed("DIVAnd")
> julia_command("using DIVAnd")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

2 participants