Help with Julia Integration in RStudio

Hello,

I’m encountering an issue with using Julia in RStudio and would appreciate your help in resolving it.

I am using RStudio to write Quarto (qmd) scripts that include R, Python, and Bash code. However, due to the large size of my files, I would like to use Julia for certain operations to improve performance. I have installed Julia, and it works fine from the terminal, but it does not work in RStudio.

When I create a Julia chunk in RStudio, I receive the following message, no matter what I include in the chunk :

Avis : l’exécution de la commande ‘’/home/gael/.julia/juliaup/julia-1.11.2+0.x64.linux.gnu/bin/julia’ ‘–startup-file=no’ ‘/home/gael/R/x86_64-pc-linux-gnu-library/4.4/JuliaCall/julia/install_dependency.jl’ ‘/usr/lib/R’ 2>&1’ renvoie un statut 139LoadError(“/home/gael/R/x86_64-pc-linux-gnu-library/4.4/JuliaCall/julia/setup.jl”, 16, ArgumentError(“Package RCall not found in current path.\n- Run import Pkg; Pkg.add("RCall") to install the RCall package.”)) Erreur dans .julia$cmd(paste0(Rhomeset, “Base.include(Main,"”, system.file(“julia/setup.jl”, :
Error happens when you try to execute command ENV[“R_HOME”] = “/usr/lib/R”;Base.include(Main,“/home/gael/R/x86_64-pc-linux-gnu-library/4.4/JuliaCall/julia/setup.jl”) in Julia.
To have more helpful error messages,
you could considering running the command in Julia directly

To resolve this, I installed the RCall package from Julia directly, which worked. However, when I return to RStudio (which I restarted before running any further tests) and try running a Julia chunk again, I get the following error regardless of what I put inside the chunk :

R session aborted. R encountered a fatal error. The session was terminated"

I am working on a Linux machine with Ubuntu 24.04.1 LTS, using Julia version 1.11.2, R version 4.4.2, and RStudio version 2024.12.0 Build 467.
I use the package RCall v0.14.6 and in R the package JuliaCall 0.17.6

If I try to launch Julia code frome R chunck with JuliaCall it fails also in the same way than describe uppon.

Could you please help me solve this issue? It would be very helpful. Thank you in advance!

1 Like

Hi and welcome! :slight_smile:

I’ve tried reproducing this and also get an error if I work inside RStudio. Curiously, the error appeared when trying to render the .qmd in RStudio’s terminal with quarto render notebook.qmd, but not when running the same from the terminal outside RStudio.

I started by creating a new project from the Julia REPL:

julia> import Pkg
julia> Pkg.activate("quarto-test")
julia> Pkg.add("RCall")

I then created a (very simple) .qmd file with R and Julia code blocks:

---
engine: julia
---

```{julia}
using RCall
```

```{r}
1 + 1
```

```{julia}
1 + 1
```

If I render this file from RStudio while no julia process is running, I run into an error suggesting that the julia process could not be started.

ERROR: NotFound: Failed to spawn 'julia': No such file or directory (os error 2)

Stack trace:
    at spawnChildInner (ext:runtime/40_process.js:186:17)
    at spawnChild (ext:runtime/40_process.js:208:10)
    at Command.spawn (ext:runtime/40_process.js:480:12)
    at ensureQuartoNotebookRunnerEnvironment (file:///Applications/quarto/bin/quarto.js:41209:26)
    at startOrReuseJuliaServer (file:///Applications/quarto/bin/quarto.js:41120:19)
    at getJuliaServerConnection (file:///Applications/quarto/bin/quarto.js:41233:30)
    at getJuliaServerConnection (file:///Applications/quarto/bin/quarto.js:41263:26)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async executeJulia (file:///Applications/quarto/bin/quarto.js:41292:18)
    at async Object.execute (file:///Applications/quarto/bin/quarto.js:41037:20)

However, if I first render the same file from the terminal (or VSCode), the julia process starts normally, and for as long as it is active, I can also render the document from within RStudio.

What happens if you try to render your notebook from the terminal with quarto render notebook.qmd?

1 Like

Hello I just did what you suggested and I have the same results. From the terminal inside Rstudio I have the same error but if I try from a classic terminal it works. I suppose that means the problem is come from Rstudio.

quarto just uses julia by default to start the server process, it seems that RStudio does something to the PATH so that it’s not found, at least that would be my only explanation why it does work from terminal or VSCode. You can set a different julia with the env variable QUARTO_JULIA=/path/to/julia but this has to be done before the server process is running.

2 Likes