Using Julia

Setting up Julia to work with the EpiAware packages.

This guide helps you set up Julia to work with the EpiAware packages, whether you are analysing data or contributing code. It assumes you are comfortable with another technical computing language (R, Python, MATLAB) but new to Julia.

It is not a guide to learning Julia. To learn the language, start with:

Install Julia

Install with juliaup, which manages Julia versions for you. Follow the instructions for your platform, then check it works:

julia --version

Set up an editor

VS Code with the Julia extension is the most common setup. It gives you an integrated REPL, a test explorer, a debugger, a plot viewer, and symbol navigation.

Environments

Julia uses per-project environments defined by a Project.toml and Manifest.toml. In the REPL, press ] to enter the package manager, then:

activate .        # use the environment in the current directory
instantiate       # install the exact versions from the manifest
add CensoredDistributions

An activate --temp environment is handy for throwaway experiments.

A productive REPL

A few packages make interactive work smoother. Install them in your global environment (the one named for your Julia version, such as @v1.11) so they are available in every project.

using Pkg
Pkg.add(["Revise", "OhMyREPL", "BenchmarkTools", "TestEnv"])
  • Revise reloads your code as you change it, without restarting Julia.
  • OhMyREPL adds syntax highlighting to the REPL.
  • BenchmarkTools measures performance.
  • TestEnv drops you into a package’s test environment.

Load them automatically by adding a ~/.julia/config/startup.jl:

atreplinit() do repl
    try
        @eval using Revise
        @eval using OhMyREPL
    catch e
        @warn "startup.jl" exception = (e, catch_backtrace())
    end
end

Revise.jl reflects your code changes without restarting Julia, which is essential when developing.

Common issues

Package not found. Usually the wrong environment is active.

] activate .        # use the environment in this directory
] instantiate       # install what the manifest says

Your changes are not taking effect. Check that Revise is loaded, through startup.jl or using Revise before you load the package. Failing that, restart Julia and load the package again.

Version conflicts when resolving an environment.

] resolve           # work out a consistent set of versions
] update            # move to newer compatible versions

Precompilation errors.

] resolve
using Pkg; Pkg.precompile()

If it persists, delete Manifest.toml and run ] instantiate to rebuild the environment from scratch.

Getting help

Next: the FAQ, or dive into the packages.