In this tutorial, you’ll learn how to get started with Julia package manager. You’ll be using the package manager to install, update and remove different Julia packages.

Using Julia Package Manager

From your terminal type in julia to move to the Julia prompt. Once you are in the Julia prompt type in the following command to get started with the Julia package manager.

# type in the Julia prompt
using Pkg

Now you are ready to install packages using the Pkg Julia package manager.

Status of Packages Installed

Using Pkg you can check the status of the packages installed. Type in the following command to check the status of packages installed.

# check package status
Pkg.status()

The above command will output the status of Julia packages installed.

julia> Pkg.status()
 Status `~/.julia/environments/v1.0/Project.toml`
 [7876af07] Example v0.5.1

Add New Packages

In order to add new packages using the Julia package manager, type in the following command.

# type the in the Julia prompt
julia> Pkg.add("HTTPClient")

The above command will add the HTTPClient package to your environment.

julia> Pkg.add("HTTPClient")
 Resolving package versions...
 Installed HTTPClient ───── v0.2.1
 Installed LibCURL ──────── v0.4.1
 Installed Compat ───────── v1.3.0
 Installed BinaryProvider ─ v0.5.2
  Updating `~/.julia/environments/v1.0/Project.toml`
  [0862f596] + HTTPClient v0.2.1
  Updating `~/.julia/environments/v1.0/Manifest.toml`
  [b99e7846] + BinaryProvider v0.5.2
  [34da2185] + Compat v1.3.0
  [0862f596] + HTTPClient v0.2.1
  [b27032c2] + LibCURL v0.4.1
  [ade2ca70] + Dates 
  [8bb1440f] + DelimitedFiles 
  [76f85450] + LibGit2 
  [a63ad114] + Mmap 
  [44cfe95a] + Pkg 
  [de0858da] + Printf 
  [3fa0cd96] + REPL 
  [ea8e919c] + SHA 
  [1a1011a3] + SharedArrays 
  [2f01184e] + SparseArrays 
  [10745b16] + Statistics 
  [cf7118a7] + UUIDs 
  [4ec0a83e] + Unicode 
  Building LibCURL → `~/.julia/packages/LibCURL/OoXMv/deps/build.log`

Now if you check the status of the packages installed you will have the HTTPClient Julia package installed.

julia> Pkg.status()
    Status `~/.julia/environments/v1.0/Project.toml`
  [7876af07] Example v0.5.1
  [0862f596] HTTPClient v0.2.1

Update Existing Packages

Updating a package is also similar to adding a package. You need to specify the package name inside the Pkg update method and the package will be updated.

julia> Pkg.update("HTTPClient")
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
  Updating `~/.julia/environments/v1.0/Project.toml`
 [no changes]
  Updating `~/.julia/environments/v1.0/Manifest.toml`
 [no changes]

Remove Installed Packages

In order to remove the Julia packages you can make use of the remove method from Pkg.

julia> Pkg.rm("HTTPClient")
  Updating `~/.julia/environments/v1.0/Project.toml`
  [0862f596] - HTTPClient v0.2.1
  Updating `~/.julia/environments/v1.0/Manifest.toml`
  [b99e7846] - BinaryProvider v0.5.2
  [34da2185] - Compat v1.3.0
  [0862f596] - HTTPClient v0.2.1
  [b27032c2] - LibCURL v0.4.1
  [ade2ca70] - Dates 
  [8bb1440f] - DelimitedFiles 
  [76f85450] - LibGit2 
  [a63ad114] - Mmap 
  [44cfe95a] - Pkg 
  [de0858da] - Printf 
  [3fa0cd96] - REPL 
  [ea8e919c] - SHA 
  [1a1011a3] - SharedArrays 
  [2f01184e] - SparseArrays 
  [10745b16] - Statistics 
  [cf7118a7] - UUIDs 
  [4ec0a83e] - Unicode

Now if you check the status of packages installed, the HTTPClient package will no longer be listed.

julia> Pkg.status()
    Status `~/.julia/environments/v1.0/Project.toml`
  [7876af07] Example v0.5.1

Wrapping It Up

In this tutorial, you learnt how to get started with using Julia package manager for installing, updating and removing Julia packages. List of registered packages can be found at the Julia package listing page.

Do let us know your thoughts in the comments below.