Julia Project Environments for Reproducible Builds
Use project-local Julia environments with committed Manifest.toml for reproducible applications and CI/CD; reserve the global environment for scratch work.
12 Aug 2026, 03:09 UTC

The decision: match environment scope to how the code runs
You clone a Julia repository, run a script, and see a package error that never occurred on your colleague's machine. The cause is usually the environment, not the code. Julia resolves packages from whichever environment is active, and the default global environment can differ between machines. If your script relies on globally installed packages, it may work on your laptop and fail in CI.
Takeaway: use a project-local environment tracked by Project.toml and Manifest.toml for applications and CI/CD. Commit Manifest.toml so every machine installs the exact same dependency tree. Reserve the global environment for interactive exploration and scratch work.
Constraints to check first
- Is this an application, a library, or exploratory analysis?
- Will the code run in CI/CD, containers, or on multiple developer machines?
- Is network access available during package installation?
- Do downstream users need to override transitive dependency versions?
Supported options compared
| Option | Best for | Reproducibility | Main risk | Commit Manifest.toml? |
|---|---|---|---|---|
Global default environment (@v#.#) | Interactive exploration, one-off scripts | Low | Version drift; script breaks on another machine | No |
| Project-local environment, manifest not committed | Libraries, internal tools | Medium | Transitive versions can shift between installs | No |
| Project-local environment, manifest committed | Applications, CI/CD, containers | High | Larger diffs; regenerate after Julia minor version changes | Yes |
Project.toml declares direct dependencies and compatibility bounds. Manifest.toml locks the full dependency tree with exact versions and content hashes. A Julia process loads only one active project environment at a time; environments are not merged automatically.
Trade-offs
The global environment is convenient because you can using Plots from any folder without setup. The downside is non-determinism: two machines can have different versions of the same package, and upgrades to one project can break another. A project-local environment without a committed manifest isolates dependencies but still allows Pkg.resolve() or Pkg.instantiate() to select new transitive versions. Committing the manifest gives the strongest reproducibility, but it forces downstream consumers to use your exact transitive choices, which is why libraries usually omit it.
Implementation: create and lock a project environment
Run these commands in a terminal at the repository root. You need ordinary user permissions and write access to the folder. Each command requires network access unless you have configured a local package registry or offline artifact cache.
# 1. Create or activate the project environment in the current folder
julia --project=. -e 'using Pkg; Pkg.activate("."); Pkg.add("DataFrames")'
# 2. Confirm the active project and locked versions
julia --project=. -e 'using Pkg; Pkg.status()'
# 3. In CI or on a clean machine, install exactly what Manifest.toml records
julia --project=. -e 'using Pkg; Pkg.instantiate()'
julia --project=. tells Julia to look for Project.toml in the current directory and activate it. Pkg.add("DataFrames") is an example; replace DataFrames with your actual dependency. Pkg.status() prints the project name and the exact versions resolved into Manifest.toml. Pkg.instantiate() downloads and installs those exact versions without re-resolving, which is what makes CI builds deterministic.
If you prefer to activate inside a Julia session rather than from the shell, use:
using Pkg
Pkg.activate(".")
Pkg.instantiate()
This only affects the current Julia process. Starting a new Julia process without --project=. returns you to the global environment.
Validation: prove the environment is isolated
- Clone the repository into a clean directory where no global packages are expected to interfere.
- Run
julia --project=. -e 'using Pkg; Pkg.status()'. The output should show the project name and the versions recorded inManifest.toml, not arbitrary globally installed versions. - Run
julia --project=. -e 'using DataFrames; println(pathof(DataFrames))'. The path should point inside the project's dependency store or the Julia depot for the locked version, not a global environment folder. - To verify CI reproducibility, run
Pkg.instantiate()on a fresh clone and compare the resultingPkg.dependencies()entries against thecompatsection ofProject.toml.
If using DataFrames resolves to a globally installed package, the project flag is being ignored or a global environment is shadowing it. Check that you launched Julia with --project=. or called Pkg.activate(".") before any using statements.
Limitations
- Commit manifest for applications, not libraries. Applications benefit from locked transitive versions. Libraries should usually omit
Manifest.tomlso downstream users are not forced into your transitive choices. - Julia minor versions are not always interchangeable. An environment instantiated under Julia 1.10 may need re-instantiation under Julia 1.11 because of compatibility changes.
- One active project per process. You cannot load dependencies from two project environments simultaneously in the same Julia session.
- Network access.
Pkg.add()andPkg.instantiate()need a registry and package sources unless you use an offline mirror or local cache.
Undo
Creating Project.toml and Manifest.toml changes repository state. To return to the global environment, delete those files from the project folder and launch Julia without --project. Any packages added to the project remain in the depot but are no longer tied to that project.