Using R and JuliaCall is not reliable without assigning R environment variables before starting R

Robert Dorazio <[email protected]>
Newsgroups gmane.comp.lang.r.general
Message-ID <CAMVm2GZV3HbBVco=HnL5x=d_=PG5ooKYVkgPRF+kJ4PvBP9cwA@mail.gmail.com>
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]]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.