100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Programming

The Julia Package Manager (Pkg)

How to use Julia's built-in Pkg to create reproducible environments, add and version packages, and understand Project.toml and Manifest.toml.

Performance & PackagesBeginner8 min readJul 10, 2026
Analogies

What Pkg Is and Why Julia Uses It

Pkg is Julia's built-in package manager, shipped as part of the standard library rather than as a bolted-on third-party tool, and it is the mechanism behind installing, updating, and removing packages as well as defining fully reproducible project environments. Every Julia project can carry its own Project.toml describing direct dependencies and a Manifest.toml pinning the exact resolved version of every package in the dependency tree, so that anyone who clones the project and runs Pkg.instantiate() gets byte-for-byte the same package versions you developed with, eliminating an entire class of 'works on my machine' bugs.

🏏

Cricket analogy: A touring squad that travels with its own kit bag containing the exact bats, pads, and ball brand it trains with never has to hope the host ground supplies something compatible — Project.toml and Manifest.toml are that kit bag, guaranteeing every teammate who clones the repo plays with identical equipment.

Activating and Managing Environments

Rather than installing every package into one shared global environment the way some language ecosystems do, Julia encourages per-project environments: running Pkg.activate(".") (or pressing ] then activate . inside the REPL) tells Pkg that any subsequent add, remove, or update should modify the Project.toml and Manifest.toml in the current directory rather than the global default environment. This isolation means two projects on the same machine can depend on completely different, even conflicting, versions of the same package without ever interfering with each other, and running Pkg.instantiate() after activating downloads and installs precisely the versions recorded in that project's Manifest.toml.

🏏

Cricket analogy: Two franchises in the same city sharing one dressing room and mixing up kit bags would cause chaos before a match, so each team gets its own separate dressing room — activating a per-project environment gives each Julia project that same separate dressing room instead of sharing one global kit.

julia
# From the Julia REPL, press ']' to enter Pkg mode, or use the Pkg API directly:
using Pkg
Pkg.activate(".")        # activate (or create) the environment in the current directory
Pkg.instantiate()        # install exactly the versions recorded in Manifest.toml
Pkg.status()             # list installed packages and their versions

# Equivalent using the Pkg REPL mode (press ']' at the julia> prompt):
# (@v1.10) pkg> activate .
# (MyProject) pkg> instantiate
# (MyProject) pkg> status

Adding, Removing, and Updating Packages

Pkg.add("PackageName") resolves and installs a package along with any compatible versions of its dependencies, recording the result in both Project.toml (the direct dependency) and Manifest.toml (the full resolved tree); Pkg.rm("PackageName") removes it, and Pkg.update() re-resolves the environment to the newest versions still permitted by any [compat] bounds declared in Project.toml. Julia's package resolver uses semantic versioning strictly, so a compat entry like DataFrames = "1" allows any 1.x release but blocks a breaking 2.0 release automatically, which is what keeps Pkg.update() from silently introducing breaking changes into a working project.

🏏

Cricket analogy: A franchise auction where a team bids for a player only within its salary cap, and the auctioneer automatically blocks any bid that would breach it, mirrors how [compat] bounds let Pkg.update() fetch newer package versions while blocking any release that would breach declared compatibility.

Running Pkg.update() inside the global default environment (rather than an activated project environment) can silently change package versions used by every unrelated script you run from that environment. Always Pkg.activate(".") a dedicated environment for real projects, and commit both Project.toml and Manifest.toml to version control for applications (Manifest.toml is often excluded for reusable libraries, since it can be overly restrictive for downstream users).

Project.toml vs Manifest.toml

Project.toml is the human-authored file listing your project's name, direct dependencies by name and UUID, and optional [compat] version bounds — it is short, readable, and meant to be edited and reviewed like any other source file. Manifest.toml, by contrast, is machine-generated and lists the complete, fully resolved dependency graph including every transitive dependency and its exact pinned version and content hash; it is what makes Pkg.instantiate() able to reproduce an environment exactly, and it should generally be regenerated by Pkg rather than hand-edited.

🏏

Cricket analogy: A team sheet naming the eleven players selected for a match is short and readable like Project.toml, while the full match scorecard recording every ball bowled, run scored, and substitution is the exhaustive, machine-generated record — that scorecard is Manifest.toml's role for a Julia project.

toml
# Project.toml (short, human-edited)
name = "MyProject"
uuid = "8f4d0f93-1234-5678-9abc-def012345678"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[compat]
DataFrames = "1"
Plots = "1.30"
julia = "1.9"

# Manifest.toml (machine-generated, excerpt)
# [[deps.DataFrames]]
# deps = ["Compat", "DataAPI", "Future", "InlineStrings", ...]
# git-tree-sha1 = "04c738083f29f86e62c8afc341f0967d8ad9e17"
# uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
# version = "1.6.1"

The Pkg REPL Mode and Everyday Commands

Pressing ] at the julia> prompt switches the REPL into Pkg mode, where you can type commands like add, rm, update, status, and test directly without wrapping them in Pkg.function(...) calls, and pressing backspace on an empty line returns to normal Julia mode. Pkg.test() (or the pkg> test command) is particularly important because it runs a package's test suite inside a temporary, freshly instantiated copy of its declared environment, catching dependency and compatibility problems that might not show up if you only ever test inside your own already-populated development environment.

🏏

Cricket analogy: Switching from a Test match mindset to a T20 mindset requires a distinct gear change in tempo and shot selection — pressing ] to enter Pkg mode is that same context switch, moving from writing Julia logic to managing the project's package 'squad'.

Common Pkg REPL commands: add PackageName installs a package; add PackageName@1.2.3 pins an exact version; rm PackageName removes one; update upgrades within compat bounds; status (or st) shows installed versions; test runs the test suite in an isolated environment; precompile forces precompilation of all dependencies ahead of time.

  • Pkg is Julia's built-in package manager, providing reproducible per-project environments rather than one shared global install.
  • Pkg.activate(".") switches Pkg to operate on the current directory's Project.toml/Manifest.toml instead of the global environment.
  • Project.toml is the short, human-edited file listing direct dependencies and [compat] bounds; Manifest.toml is the machine-generated, fully resolved dependency graph.
  • Pkg.add, Pkg.rm, and Pkg.update manage packages, and [compat] entries use semantic versioning to prevent update from introducing breaking changes.
  • Pkg.instantiate() installs the exact versions recorded in Manifest.toml, making environments reproducible across machines.
  • Press ] at the julia> prompt to enter Pkg's dedicated REPL mode; backspace on an empty line returns to normal Julia.
  • Pkg.test() runs a package's tests inside a freshly instantiated environment, catching dependency issues invisible in an already-populated dev environment.

Practice what you learned

Was this page helpful?

Topics covered

#Programming#JuliaStudyNotes#TheJuliaPackageManagerPkg#Julia#Package#Manager#Pkg#StudyNotes#SkillVeris#ExamPrep