Skip to content
AgileLogics
6 min read

Packages and Environments

Prerequisites: Modules

Julia's package manager is Pkg. Press ] in the REPL to enter package mode:

(@v1.13) pkg> add DataFrames CSV
(@v1.13) pkg> status
(@v1.13) pkg> update
(@v1.13) pkg> remove CSV
(@v1.13) pkg> ?                 # help for package commands

The prompt shows the active environment. @v1.13 is your default, shared environment — fine for tools like Revise.jl, but projects should have their own.

Project environments

An environment is a folder with two files:

  • Project.toml — the packages you depend on directly, and their allowed versions (compat).
  • Manifest.toml — the exact version of every package, including indirect dependencies. Committing it makes the project fully reproducible.
$ mkdir MyAnalysis && cd MyAnalysis
$ julia
(@v1.13) pkg> activate .
  Activating new project at `~/MyAnalysis`

(MyAnalysis) pkg> add CSV
   Resolving package versions...
    Updating `~/MyAnalysis/Project.toml`
  [336ed68f] + CSV v1.1.0
    Updating `~/MyAnalysis/Manifest.toml`
  [336ed68f] + CSV v1.1.0
  [944b1d66] + CodecZlib v0.7.9
  ...

(MyAnalysis) pkg> compat CSV 1.1

The resulting Project.toml:

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"

[compat]
CSV = "1.1"

Every package has a unique ID (UUID); the compat entry "1.1" allows any version from 1.1.0 up to (but not including) 2.0.

Using an environment

julia --project=. analysis.jl      # run a script in this folder's environment
julia --project                     # same: looks for Project.toml upward
(MyAnalysis) pkg> instantiate       # install everything in Manifest.toml

Someone who clones your project runs instantiate once and gets exactly the same package versions you used.

The same from code

# illustrative — installs packages from the internet
using Pkg
Pkg.activate(".")
Pkg.add(["DataFrames", "CSV"])
Pkg.status()

Scripts and CI pipelines use the Pkg API; the ] mode is a shortcut for the same functions.

Finding packages

Registered packages are listed in the General registry — browse them on juliahub.com or search GitHub. Standard libraries (like LinearAlgebra, Statistics, Dates, Random, Test) ship with Julia and need no add.

Good habits

  • One environment per project; keep the default environment small.
  • Add [compat] entries for every dependency before sharing code.
  • Commit Manifest.toml for applications and analyses (exact reproducibility); packages usually don't commit it.