3  Prerequisites

This chapter gets your computer ready for the rest of the book. By the end you will have installed Julia and an editor, downloaded the book’s data and exercises, and run a first script that draws a plot.

Follow the steps in order. Where they differ between operating systems, pick your system’s tab. Plan for about an hour the first time — most of it is waiting while packages install — and keep an internet connection until Section 3.6 is done. If a step does not behave as described, see Section 3.9.

NoteWhat you will install
What Why
Julia (through juliaup) the language itself
VS Code and its Julia extension where you write and run code
The book folder data, exercises and the list of packages the book uses
The book’s packages data frames, plots and models, at the exact versions the book was built with

You do not need git, R or Quarto.

3.1 Step 1: open a terminal

A terminal is a window where you type commands instead of clicking. You need it only for installing Julia. After that, everything we do in this book happens inside VS Code.

Open the Start menu, type PowerShell and open Windows PowerShell (or Terminal, on Windows 11).

Press Cmd+Space, type Terminal and press Return.

Press Ctrl+Alt+T on most distributions, or look for Terminal in the applications menu.

To run a command, paste it into the terminal and press Enter. Pasting is Ctrl+V on Windows, Cmd+V on macOS and Ctrl+Shift+V in most Linux terminals.

3.2 Step 2: install Julia

Use juliaup, the official installer and version manager. Do not install Julia through a system package manager (apt, brew), which tends to ship outdated versions.

winget install --name Julia --id 9NJNWW8PVKMN -e -s msstore

If Windows asks you to accept the Microsoft Store terms, type Y and press Enter.

curl -fsSL https://install.julialang.org | sh

The installer asks whether to proceed with the default settings. Press Enter to accept them.

When it finishes, close the terminal and open a new one — the julia command only becomes available in new terminals. Then check the installation:

julia --version

The book was built with Julia 1.12, but juliaup installs the latest stable release, which may be newer (1.13 as of October 2026). To use the same version as the book, run:

juliaup add 1.12
juliaup default 1.12

and check again with julia --version, which should print something like julia version 1.12.6. Use 1.12 even if you already have a newer version: with another version, Pkg.instantiate() in Step 6 warns that Manifest.toml was resolved with a different Julia version, some package versions may not be exactly the book’s, and check("setup") in Step 7 flags the problem.

Now type julia and press Enter to start Julia itself. The prompt changes to julia>; type 1 + 1, press Enter, and Julia answers 2. Leave with exit().

Later, juliaup update upgrades Julia and juliaup status lists the installed versions.

3.3 Step 3: download the book folder

The book comes with a folder that holds the example data, the exercise checker and the list of packages the book needs.

  1. Go to https://github.com/esantos2ua/EcologicalAnalysesInJulia.

  2. Click the green Code button, then Download ZIP.

  3. Unzip the file:

    Right-click the downloaded file and choose Extract All…. Work in the extracted folder, not inside the ZIP: files opened from inside a ZIP are read-only copies.

    Double-click the downloaded file.

    Right-click the file and choose Extract Here, or run unzip on it.

  4. Move the extracted folder, EcologicalAnalysesInJulia-main, somewhere permanent such as your Documents folder. You can rename it, but avoid putting it inside Downloads, which some systems clean up automatically.

Inside you should see, among others, the folders data and exercises and the files Project.toml and Manifest.toml.

TipIf you already use git

Clone the repository instead of downloading the ZIP; git pull then brings in updates to the book:

git clone https://github.com/esantos2ua/EcologicalAnalysesInJulia.git

3.4 Step 4: install VS Code

VS Code with the official Julia extension is the standard editor for Julia: it offers an integrated REPL (the console where code runs), a variable browser, a plot pane, a debugger and line-by-line evaluation — the functional equivalent of RStudio.

  1. Install VS Code from https://code.visualstudio.com and open it.
  2. Install the Julia extension. Open the Extensions panel (Ctrl+Shift+X; Cmd+Shift+X on macOS), search for Julia and install the extension published by julialang. It finds the Julia installed by juliaup on its own.

If you prefer an open-source build, VSCodium is VS Code compiled from the same MIT-licensed source without Microsoft’s telemetry, and installs the same Julia extension from the Open VSX registry. Antigravity, another editor derived from VS Code, also runs the same extension. Everything in this book applies to all three (at least as far as I have tested). Other options are Pluto.jl (reactive notebooks, excellent for teaching) and any editor with LSP support through LanguageServer.jl.

3.5 Step 5: open the book folder

  1. Open a folder, not a file. In VS Code, use File → Open Folder… and choose the book folder from Section 3.3. If VS Code asks whether you trust the authors of the files, answer yes. The folder you open determines both where Julia looks for files and which packages it uses.
  2. Check the environment. The status bar at the bottom of the window should read Julia env: followed by the name of the book folder. If it shows something like Julia env: v1.12 instead, click that entry and choose the book folder.
  3. Start the REPL. Open the Command Palette (Ctrl+Shift+P; Cmd+Shift+P on macOS) and run Julia: Start REPL, or press Alt+J then Alt+O. A panel opens at the bottom with the julia> prompt, already inside the book folder and its environment.

In R

Opening a folder in VS Code plays the role of opening an .Rproj in RStudio: it sets the working directory. Unlike RStudio, it also selects the package environment (Section 3.10), so the right package versions come along automatically.

3.6 Step 6: install the book’s packages

Click in the REPL panel and run:

using Pkg
Pkg.instantiate()

This reads Manifest.toml, downloads every package the book uses at the exact version listed there, and compiles them.

WarningThis takes a while

The first time, Pkg.instantiate() can take from several minutes to half an hour, depending on your computer and connection. Plotting and modelling packages are large, and Julia compiles them ahead of time so they run fast later. Progress lines keep appearing while it works; let it finish and do not close VS Code. You only do this once per computer.

NoteWhat does compiling mean?

Compiling means translating human-readable code directly into machine code — the instructions the computer’s processor executes natively.

While languages such as R and Python interpret code line by line as it runs, Julia does this translation ahead of time (in what is called precompilation). That takes some patience when you first install the packages, but it is what makes your analyses and plots run at full speed afterwards (see more on compilation latency in Section 1.3).

3.7 Step 7: check that everything works

The book folder includes a checker that you will also use for the exercises from Chapter 4 on. Load it and ask it to check your setup:

include("exercises/check.jl")
check("setup")

If everything is in place you will see:

✓ Julia 1.12.6
✓ Working folder is the book folder
✓ Book environment is active
✓ Data file found: data/ponds.csv
✓ All 19 packages installed
Ready. Continue with the first script.

A line with ✗ says what is wrong and how to fix it; Section 3.9 has more detail.

3.8 Step 8: a first script

With the book folder open and the REPL running, create a file called first-steps.jl in the folder root (File → New File, or Alt+J then Alt+N) and paste:

## Load packages
using CSV, DataFrames, CairoMakie

## Where am I?
pwd()               # the folder you opened
readdir("data")     # files inside data/

## Read the example data
ponds = CSV.read(joinpath("data", "ponds.csv"), DataFrame)
first(ponds, 5)
describe(ponds)

## Plot richness against pond area
fig = Figure()
ax = Axis(fig[1, 1]; xlabel = "Pond area (m²)", ylabel = "Species richness",
          xscale = log10)
scatter!(ax, ponds.area_m2, ponds.richness)
fig

Lines starting with ## split the script into cells. Put the cursor in the first cell and press Alt+Enter to run it, then keep going cell by cell (Alt+Shift+Enter runs the cell and jumps to the next one). A few things to notice:

  • Loading packages is slow the first time in each session — that is the compilation latency discussed in Section 1.3. Later cells run immediately.
  • Paths are relative to the folder you opened. pwd() confirms it, which is why joinpath("data", "ponds.csv") works without typing the full path. joinpath inserts the right separator on every operating system.
  • describe is your first data check. It shows that canopy has 7 missing values and that area_m2 is strongly right-skewed (median around 149 m², maximum near 2000 m²) — which is why the plot uses a log scale.
  • xlabel = ... and xscale = log10 are keyword arguments, given by name rather than by position, as in R. Section 10.2 explains the details.

The shortcuts you will use constantly:

Shortcut Action
Shift+Enter run the current line or selection, then move to the next
Ctrl+Enter run the current line or selection, staying put
Alt+Enter run the current cell (a block delimited by ## lines)
Alt+J, Alt+R restart the REPL
Ctrl+C in the REPL interrupt a running computation

On macOS, Alt is the Option key; Ctrl stays Ctrl. Shortcuts and menu names were checked against version 1.249 of the Julia extension in September 2026.

Inspecting the environment. Click the Julia icon in the Activity Bar (the left-hand strip). The Workspace panel lists every variable in the session — ponds, fig, ax — with its type and size; expand an entry to look inside. For a data frame, hover over its name and click the Open in VS Code icon, or run vscodedisplay(ponds) in the REPL, to open it in a spreadsheet-like grid — the equivalent of RStudio’s View().

Plots. Evaluating fig opens the figure in the plot pane, a VS Code tab. The Plot Navigator panel, below the Workspace, keeps the history of the session’s plots; with the plot pane focused, the arrow keys move through it. To save a figure to disk, use save("richness-area.png", fig).

3.9 Troubleshooting

julia is not recognized / command not found.
Close every terminal and open a new one; the installer only updates new terminals. If it still fails, run the installation command of Section 3.2 again.
Windows: winget is not recognized.
winget comes with the App Installer app. Update App Installer from the Microsoft Store, or search for Julia in the Microsoft Store and install it from there — it is the same juliaup installer.
Linux: curl: command not found.
Install curl with your distribution’s package manager (for example sudo apt install curl on Ubuntu), then repeat Section 3.2.
VS Code says it cannot find Julia.
In a terminal, run where.exe julia (Windows) or which julia (macOS, Linux) and copy the path it prints. In VS Code, open the settings (Ctrl+,; Cmd+, on macOS), search for julia.executablePath and paste the path there. Then restart VS Code.
The status bar shows Julia env: v1.12 (or another version) instead of the book folder.
VS Code has the wrong folder open, or a single file. Use File → Open Folder… and choose the book folder itself — the one containing Project.toml — not a folder above or inside it. Then restart the REPL (Alt+J, Alt+R).
include("exercises/check.jl") fails with No such file or directory.
The REPL is not running in the book folder. pwd() shows where it is. Open the book folder as above and restart the REPL.
Pkg.instantiate() seems frozen.
It is probably compiling; this is the slow part. As long as new lines keep appearing every few minutes, wait. If it stopped with an error — for example because the connection dropped — run Pkg.instantiate() again; it picks up where it left off.
Package CairoMakie not found in current path (or another package).
Either the book environment is not active (check the status bar) or Section 3.6 has not finished. check("setup") tells you which.
The first using CairoMakie in each session takes a minute.
That is normal: Julia compiles code the first time it runs in a session (Section 1.3). Later commands are fast.

3.10 Under the hood: project environments

You have already used an environment without having to think about it: that is what the status bar in Section 3.5 shows. This section explains what it is — the concept that differs most from common practice in R.

In R, install.packages() installs into a global library shared by all your projects. In Julia, each project has its own environment, described by two files:

  • Project.toml — the direct dependencies you declared.
  • Manifest.toml — the full resolved dependency tree, with exact versions of everything.

Together they make an analysis reproducible by construction: anyone who has your project folder and runs Pkg.instantiate() gets exactly your versions — which is what you did in Section 3.6.

In R

Project.toml + Manifest.toml play the role of renv.lock, but they are part of the language rather than an add-on package. Activating an environment is the default operation, not the exception.

Pkg.status() lists the packages in the active environment:

using Pkg
Pkg.status()
Status `~/Documents/Repos/EcologicalAnalysesInJulia/Project.toml`
⌃ [cbdf2221] AlgebraOfGraphics v0.13.1
⌅ [336ed68f] CSV v0.10.17
⌃ [13f3f980] CairoMakie v0.15.13
⌅ [324d7699] CategoricalArrays v0.10.9
  [a93c6f00] DataFrames v1.8.2
  [31c24e10] Distributions v0.25.131
  [8f03c58b] Effects v1.7.1
  [38e38edf] GLM v1.9.5
⌃ [09f84164] HypothesisTests v0.11.8
⌃ [ff71e718] MixedModels v5.8.2
⌅ [ce6b1742] RDatasets v0.7.7
⌃ [10745b16] Statistics v1.11.4
  [2913bbd2] StatsBase v0.34.13
  [3eaba693] StatsModels v0.7.10
  [79ddc9fe] TidierCats v0.2.2
  [fe2206b3] TidierData v0.17.2
  [8ae5e7a9] TidierFiles v0.3.2
  [337ecbd1] TidierPlots v1.0.0
  [9a3f8284] Random v1.11.0
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated`

This book was built with:

versioninfo()
Julia Version 1.12.6
Commit 15346901f00 (2026-04-09 19:20 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 10 × Apple M5
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, apple-m1)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)
Environment:
  JULIA_LOAD_PATH = @:@stdlib

3.11 Under the hood: Quarto

You do not need this section to follow the book. It is for readers who want to build the book themselves or write documents like it.

This book is written in Quarto, the direct successor to bookdown. Since version 1.5, Quarto executes Julia blocks natively, without going through Jupyter.

```{julia}
#| label: example
1 + 1
```

The repository’s README.md explains how to render the book.

Challenges

  1. In the REPL, press ] to enter package mode (the prompt turns blue; Backspace leaves it). Run activate my-test and then add DataFrames: this creates an environment in a new folder, my-test. Inspect the Project.toml it generated, then run activate . to return to the book’s environment.
  2. Delete my-test/Manifest.toml, activate my-test again and run resolve. What changes?
  3. Run first-steps.jl (Section 3.8) cell by cell. In the Workspace panel, which types did CSV.jl assign to the region and canopy columns, and why is the type of canopy different from that of area_m2?