I need access to a pre-existing project environment within JuliaCall.
The following MWE does not work:
MWE:
Create the ‘pre-existing’ environment
# run this in the terminal
$ cd ~/
$ mkdir /tmp/testenv && cd /tmp/testenv
$ julia
julia> using Pkg; Pkg.activate("/tmp/testenv")
julia> Pkg.add(DataFrames)
Accessing it in R [testjuliacall.R
]
# testjuliacall.R
library(JuliaCall)
Sys.setenv(JULIA_PROJECT="/tmp/testenv")
julia_library("DataFrames")
Problem
Running testjuliacall.R
produces the following error:
Julia version 1.6.0 at location /usr/local/julia-1.6.0/bin will be used.
Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.
Error: Error happens in Julia.
ArgumentError: Package DataFrames not found in current path:
- Run `import Pkg; Pkg.add("DataFrames")` to install the DataFrames package.
Stacktrace:
[1] require(into::Module, mod::Symbol)
@ Base ./loading.jl:871
[2] eval
@ ./boot.jl:360 [inlined]
[3] eval_string(x::String)
@ Main.JuliaCall ~/R/x86_64-pc-linux-gnu-library/4.0/JuliaCall/julia/setup.jl:195
[4] docall(call1::Ptr{Nothing})
@ Main.JuliaCall ~/R/x86_64-pc-linux-gnu-library/4.0/JuliaCall/julia/setup.jl:168