Using Julia
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:
- Julia documentation, getting started
- Julia learning resources
- Modern Julia Workflows, practical setup and best practice
- Noteworthy differences from other languages
Install Julia
Install with juliaup, which manages Julia versions for you. Follow the instructions for your platform, then check it works:
julia --versionSet 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 CensoredDistributionsAn 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
endRevise.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 saysYour 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 versionsPrecompilation errors.
] resolve
using Pkg; Pkg.precompile()If it persists, delete Manifest.toml and run ] instantiate to rebuild the environment from scratch.
Getting help
- Julia Discourse, the community forum
- Julia Slack and Zulip
- For EpiAware questions, the epinowcast forum; each package’s GitHub issue tracker is for bugs and feature requests