Skip to contents

This section show how to install Julia and setup your R enviroment to use rjuliabugs package.

See also, JuliaBUGS Documentation, and JAGS Source Code, for a more complete documentation on JuliaBUGS and JAGS sampler, respectively

Installing Julia

We recommend installing Julia using juliaup, the official Julia version manager. It provides a reliable and maintainable way to install, update, and manage Julia versions across platforms. Using juliaup is preferred over downloading Julia manually because it makes upgrading Julia seamless and safe, supports managing multiple versions, and ensures compatibility with R-Julia integration tools like JuliaCall. To install, follow the instructions:

Windows (via PowerShell)

Open PowerShell (as Administrator) and run:

winget install --id=JuliaLang.Julia -e

Requires Windows 10/11 with winget available.

macOS (via Homebrew)

If you use Homebrew, run:

brew install juliaup
juliaup add release

This installs juliaup and sets the latest stable Julia version as default.

Ubuntu (via APT)

On recent Ubuntu versions, you can install via APT:

sudo apt update
sudo apt install juliaup
juliaup add release

If juliaup is not available via APT on your system, follow manual installation instructions at the Juliaup GitHub page.

Verify Installation

After installation, open a terminal and run:

julia

This should start the Julia REPL with the installed version. You are now ready to use Julia with rjuliabugs.

Troubleshooting JuliaCall setup

The rjuliabugs package relies on the JuliaCall package to communicate with Julia from R. Errors may occur if Julia is not properly installed or if JuliaCall cannot locate the Julia binary. The most common errors include:

Error type: “Julia Not Found”

The JULIA_HOME environment variable tells R where to find Julia. If it’s not set correctly, rjuliabugs will not be able to communicate with Julia via JuliaCall.

  1. Open your terminal or command prompt.
  2. Check if JULIA_HOME is set by running:
echo $JULIA_HOME

(On Windows PowerShell use: echo $Env:JULIA_HOME)

  1. If empty or incorrect, and you installed Julia using juliaup, the Julia binary is typically located at:
~/.juliaup/bin

You can set the environment variable for the current session with:

export JULIA_HOME="$HOME/.juliaup/bin"

(On Windows PowerShell use: $Env:JULIA_HOME="$HOME/.juliaup/bin“)

Replace the path with the correct location if your installation differs (e.g., if you’re on Windows, it might be something like "C:/Users/YourName/AppData/Local/Programs/Julia-1.x.x/bin").

  1. To make this setting permanent (so you don’t need to set it every time):

    • On macOS/Linux:
      Open your shell configuration file (e.g., .bashrc, .zshrc) with a text editor:

      nano ~/.bashrc

      or

      nano ~/.zshrc  

      Add the following line at the end of the file:

      export JULIA_HOME="$HOME/.juliaup/bin"  

      Save and exit (Ctrl+O, Enter, Ctrl+X in nano).
      Then reload your shell configuration or restart your terminal:

      source ~/.bashrc

      (or source ~/.zshrc if using zsh)

    • On Windows:

      1. Search for “Environment Variables” in the Start menu and open “Edit the system environment variables.”
      2. Click “Environment Variables.”
      3. Under “User variables” or “System variables,” click “New…”
      4. Set the variable name as JULIA_HOME and the value as the path to Julia’s binary installed by juliaup (e.g., C:\Users\your_user\AppData\Local\Microsoft\WindowsApps).
      5. Click OK to save all dialogs.
      6. Restart your terminal or R session for changes to take effect.
  2. Verify it is set correctly by re-running:

echo $JULIA_HOME  

(or in R use: Sys.getenv("JULIA_HOME"))

Setting JULIA_HOME correctly ensures that JuliaCall can launch Julia, which is required for rjuliabugs to function.

Error type: “R_HOME not found”

To ensure rjuliabugs works correctly, set the R_HOME environment variable so Julia can locate your R installation.

  1. Open your terminal or command prompt.
  2. Check if R_HOME is set by running:
echo $R_HOME

(on Windows PowerShell use echo $Env:R_HOME)

  1. If empty, open R and run:
  1. Copy the printed R installation path.
  2. Set the environment variable in your terminal session with:
export R_HOME="PASTE_YOUR_PATH_HERE"

(On Windows PowerShell, use: $Env:R_HOME="PASTE_YOUR_PATH_HERE")

  1. To make this setting permanent (applies every time you open a terminal or run R):

    • On macOS/Linux:
      Open your shell configuration file with a text editor (e.g., nano):

      nano ~/.bashrc

      or if you use zsh:

      nano ~/.zshrc

      Add the line:

      export R_HOME="PASTE_YOUR_PATH_HERE"

      Save and exit (Ctrl+O, Enter, Ctrl+X in nano).
      Then reload your shell configuration or restart your terminal:

      source ~/.bashrc

      (or source ~/.zshrc if using zsh)

    • On Windows:

      1. Search for “Environment Variables” in the Start menu and open “Edit the system environment variables.”
      2. Click “Environment Variables.”
      3. Under “User variables” or “System variables,” click “New…”
      4. Set the variable name as R_HOME and the value as the full R path you copied.
      5. Click OK to save all dialogs.
      6. Restart your terminal or R session for changes to take effect.
  2. Verify by reopening the terminal and running the echo command from step 2.

This ensures Julia, when called from R via JuliaCall, can find your R installation and prevents initialization errors in rjuliabugs.

Other installations issues

Many of the most common installation problems related to JuliaCall are well documented in the Troubleshooting and Ways to Get Help section of the JuliaCall GitHub page.

If you encounter any issues while setting up rjuliabugs on your system that are not covered there, feel free to open an issue on this repository. We’re happy to help!