Robert Dorazio
2025-Oct-26 23:06 UTC
[R] Using R and JuliaCall is not reliable without assigning R environment variables before starting R
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]]
Ivan Krylov
2025-Oct-27 09:42 UTC
[R] Using R and JuliaCall is not reliable without assigning R environment variables before starting R
? Sun, 26 Oct 2025 16:06:08 -0700 Robert Dorazio <rmdorazio at gmail.com> ?????:> FYI: I am using Julia 1.12.1, R 4.5.1, and Ubuntu 24.04.Thank you for specifying the operating system version that you're using! You're probably suffering from the conflict between shared libraries bundled by Julia and the ones provided by your operating system: https://github.com/JuliaInterop/JuliaCall/issues/238#issuecomment-2620093298 ...which had a workaround merged a few hours ago: https://github.com/JuliaInterop/JuliaCall/pull/265 Try installing the latest version of JuliaCall from GitHub. Due to the conflict between the ways R and Julia are built and distributed, there may be other incompatibilities as well. -- Best regards, Ivan