liveBook · Manning

Package mode

As explained in Julia as a Second Language

Package mode is a Julia package-management REPL mode that accepts commands for creating and managing packages.

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

How Julia as a Second Language covers it

How deep it goes
Explains practical commands and Project.toml or Manifest.toml effects, while deferring nested module organization.
Examples
Demonstrates job and hobby environments, CairoMakie version pinning, ElectronDisplay, ToyGeometry, Dates, and Base64.
What it assumes
Assumes familiarity with the Julia REPL and basic shell navigation, while teaching environments and package structure incrementally.
What you can do after
Operate/configure Julia environments by activating projects, adding or removing dependencies, inspecting status, and generating packages.
How it connects
Connects packages with environments, modules, Project.toml, Manifest.toml, dependencies, and version resolution.

This explainer was generated by Manning's knowledge graph from the text of Julia as a Second Language. The section links point to the parts of the book it draws on.