Package mode is Julia’s package-management REPL mode, entered by pressing ]. It activates environments and adds or removes dependencies without mixing project requirements. section 16.1
Separate environments keep hobby and work projects independent: one can use the latest CairoMakie, while another pins CairoMakie 0.5.10. The prompt displays the active environment. section 16.1
Common package-mode commands include:
- activate selects or creates an environment, such as activate job. section 16.1
- add installs a package or a specified version, such as add CairoMakie@0.5.10. section 16.1
- status lists the packages recorded in the active Project.toml. section 16.1
- rm removes a dependency from the active environment. section 16.1
- generate creates a minimalist package with Project.toml and src/PackageName.jl. section 16.2.1
Creating a package
From a hobby directory, run generate ToyGeometry, activate ToyGeometry/, then add Dates Base64. Project.toml records direct dependencies; Manifest.toml records resolved dependencies such as Printf and Unicode. section 16.2.1
(job) pkg> add CairoMakie@0.5.10 #1
Updating registry at `~/.julia/registries/General.toml`
Resolving package versions...
[13f3f980] + CairoMakie v0.5.10
Updating `~/dev/job/Manifest.toml`
(job) pkg> add ElectronDisplay #2
Resolving package versions...
Updating `~/dev/job/Project.toml`
[d872a56f] + ElectronDisplay v1.0.1
Updating `~/dev/job/Manifest.toml`
(job) pkg> status #3
Status `~/dev/job/Project.toml`
[13f3f980] CairoMakie v0.5.10
[d872a56f] ElectronDisplay v1.0.1
Follow a complete session that pins CairoMakie for a work environment, adds ElectronDisplay, and checks the resulting status. section 16.1
