JuliaInterop / RCall.jl

Call R from Julia
Other
319 stars 59 forks source link

using RCall quits Julia with the error "cannot find system Renviron" #481

Closed mangelett closed 4 months ago

mangelett commented 1 year ago

Hi,

I'm trying to call RCall in Julia 1.8.5 but it fails with the following error:

[root@noun ~]# export LD_LIBRARY_PATH=/softs/R/R-4.2.2/lib:$LD_LIBRARY_PATH
[root@noun ~]# julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.5 (2023-01-08)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using RCall
cannot find system Renviron

The operating system is Rocky Linux 8.6. Julia is installed on the folder /softs/julia/julia-1.8.5 and R is installed on the folder /softs/R/R-4.2.2. Before installing RCall in Julia, I define the following environment variables:

export R_HOME=/softs/R/R-4.2.2/
export LD_LIBRARY_PATH=/softs/R/R-4.2.2/lib/:$LD_LIBRARY_PATH

Then in Julia, I launch:

using Pkg
Pkg.add("RCall")
 Pkg.build("RCall")
    Building Conda → `/softs/julia/julia-1.8.5/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/e32a90da027ca45d84678b826fffd3110bb3fc90/build.log`
    Building RCall → `/softs/julia/julia-1.8.5/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/2c0ffd39860c9a48259a0f57214ced2024ab63bc/build.log`

The building of RCall seems to work but I can't use it. Renviron is currently in the folder /softs/R/R-4.2.2/lib64/R/etc/. I tried to add this folder to the LD_LIBRARY_PATH variable or to the PATH variable but it doesn't solve the problem. I also give the largest rights to the file Renviron (chmod 777). But it doesn't solve the issue.

Here is the result of versioninfo() in julia if it helps:

versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65ea (2023-01-08 06:45 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × Intel(R) Xeon(R) Silver 4108 CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, skylake-avx512)
  Threads: 1 on 32 virtual cores
Environment:
  LD_LIBRARY_PATH = /softs/R/R-4.2.2/lib:/softs/R/R-4.2.2/lib:/softs/R/R-4.2.2/lib:/softs/R/R-4.2.2/lib64/R/etc/:/softs/R/R-4.2.2/lib:/opt/ohpc/pub/mpi/libfabric/1.13.0/lib:/opt/ohpc/pub/mpi/ucx-ohpc/1.11.2/lib:/opt/ohpc/pub/libs/hwloc/lib:/opt/ohpc/pub/mpi/openmpi4-gnu9/4.1.1/lib:/opt/ohpc/pub/compiler/gcc/9.4.0/lib64
  JULIA_DEPOT_PATH = /softs/julia/julia-1.8.5
  JULIA_HISTORY = /root/.julia/logs/repl_history.jl
  JULIA_DIR = /softs/julia/julia-1.8.5/
palday commented 4 months ago

Since R also uses the R_HOME environment variable, can you try setting it via Julia Preferences instead of environment variables? This is a new feature, but it might help here. Then you wouldn't need to set R_HOME and LD_LIBRARY_PATH.

mangelett commented 4 months ago

Hi,

I defined the file LocalPreferences.toml in /softs/julia/julia-1.8.5/environnement/v1.8 and define in the file Rhome and Rlib. In julia, when I try using RCall it fails with:

 ERROR: could not load library "/softs/R/R-4.4.0/lib64/R/lib/libR.so"
libRblas.so: cannot open shared object file: No such file or directory
ERROR: InitError: Try adding /softs/R/R-4.4.0/lib64/R/lib to the "LD_LIBRARY_PATH" environmental variable and restarting Julia.

But when I quit julia and export the path in LD_LIBRARY_PATH with export LD_LIBRARY_PATH=/softs/R/R-4.4.0/lib64/R/lib/:$LD_LIBRARY_PATH, the julia command using RCall succeed and the examples given in https://juliainterop.github.io/RCall.jl/stable/gettingstarted/ work.

So thank you: i can solve the issue by adding the R library in the path.