[R] Using R and JuliaCall is not reliable without assigning R environment variables before starting R
Robert Dorazio
rmdor@z|o @end|ng |rom gm@||@com
Mon Oct 27 00:06:08 CET 2025
Suppose the file "sourceCode.R" contains an R script that calls a Julia
function using julia_call(), which is defined in the R package JuliaCall.
If R is started in a Linux terminal using the command "R", then the R
command "source(sourceCode.R)" may produce a segmentation fault (core
dumped).
In contrast, if R is started in a Linux terminal using the following code:
R_HOME=/usr/lib/R
export R_HOME
R_SHARE_DIR=/usr/share/R/share
export R_SHARE_DIR
R_INCLUDE_DIR=/usr/share/R/include
export R_INCLUDE_DIR
R_DOC_DIR=/usr/share/R/doc
export R_DOC_DIR
exec /usr/lib/R/bin/exec/R
then the R command "source(sourceCode.R)" executes without errors.
Evidently, explicitly setting these R-related environment variables to
their correct system paths BEFORE running R is needed to ensure that both R
and any external libraries it calls (like JuliaCall) have the precise,
necessary information to locate all R components.
This correct path information allows the underlying inter-language
connection to be established cleanly, preventing the memory access error.
Unfortunately, running R from the Linux terminal is not nearly as
convenient as running R within Emacs (or another editor), where R code can
be edited and run more easily. Does anyone have an alternative solution to
this problem?
FYI: I am using Julia 1.12.1, R 4.5.1, and Ubuntu 24.04.
[[alternative HTML version deleted]]
More information about the R-help
mailing list