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 ensured 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?
I get a segment fault, also, on substantially the same setup. This, however, works
# miscellaneous.jl
function agm(a, b; tol = 1.0e-15)
a0 = a; b0 = b
while abs(b0-a0) >= tol
a0, b0 = (a0 + b0)/2.0, sqrt(a0 * b0)
end
return (a0 + b0) / 2.0
end
My original post should have stated:
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).
That is, a segmentation fault is not produced for every R source code. But occurrence of a segmentation fault is certainly not uncommon.
exec [-cl] [-a name] [command [arguments]]
If command is specified, it replaces the shell. No new process is created. The arguments become the arguments to command. If the -l option is supplied, the shell
places a dash at the beginning of the zeroth argument passed to command. This is what login(1) does. The -c option causes command to be executed with an empty envi-
ronment. If -a is supplied, the shell passes name as the zeroth argument to the executed command. If command cannot be executed for some reason, a non-interactive
shell exits, unless the execfail shell option is enabled. In that case, it returns failure. An interactive shell returns failure if the file cannot be executed. A
subshell exits unconditionally if exec fails. If command is not specified, any redirections take effect in the current shell, and the return status is 0. If there
is a redirection error, the return status is 1.
Replacing the shell is probably something special, which may have some use cases. I never had to use it, that’s why I stumbled over it. So, perhaps, there is not a problem at all when you just run R with
/usr/lib/R/bin/exec/R
I didn’t do any experiments, just a guess into nothing. You may try if you like.
The idea is to assign the R environment variables and to launch R using one shell script.
However, this is no longer needed because the problems with the JuliaCall package have been resolved in a VERY RECENT update of the package, which can be downloaded from https://github.com/JuliaInterop/JuliaCall