Julia: is there a function to obtain the version number of a package?

Viewed 396

I see that Pkg.status("PkgName") prints something like this Pkg v0.12.0 to the REPL.

I tried to @edit Pkg.status("Pkgname") but encountered some macro code that I don't understand.

What's the easiest way to obtain the version number of a package in the current activate environment?

2 Answers

Pkg.installed() does give you the version of all installed packages as version strings, but it is deprecated and is likely to be removed in future versions of julia

julia> Pkg.installed()
ā”Œ Warning: Pkg.installed() is deprecated
ā”” @ Pkg ~/julia/usr/share/julia/stdlib/v1.5/Pkg/src/Pkg.jl:561
Dict{String,VersionNumber} with 81 entries:
  "Interact"                    => v"0.10.3"
  "ForwardDiff"                 => v"0.10.12"
  "UMAP"                        => v"0.1.6"
  "Juno"                        => v"0.8.2"

Currently you can use Pkg.dependencies() to get all information about all packages, as it was discussed here. For example

using Pkg

julia> filter(x-> x.second.name == "Crayons", Pkg.dependencies()) |> x -> first(x)[2].version   
v"4.0.1"
Related