5

How do I find out my package version in Julia? Is there a command which shows the version that's being used?

Davi Barreira
  • 1,597
  • 11
  • 19

1 Answers1

5

It is easy to check the version that is installed in the current project environment:

(@v1.5) pkg> st DataFrames
Status `D:\.julia\environments\v1.5\Project.toml`
  [a93c6f00] DataFrames v0.22.1 `D:\.julia\dev\DataFrames`

It is more difficult to get a version of currently loaded package (that might be different if you e.g. changed project environment or upgraded the package in the same Julia session). For this you can use:

julia> using Pkg

(@v1.5) pkg> st DataFrames
Status `D:\.julia\environments\v1.5\Project.toml`
  [a93c6f00] DataFrames v0.22.2

julia> Pkg.TOML.parsefile(joinpath(String(first(methods(getfield(DataFrames, :eval))).file), "..", "..", "Project.toml"))["version"]
"0.22.1"

(in this example I have first loaded DataFrames.jl 0.22.1 then after having loaded it upgraded it to 0.22.2)

(you can have find more details why this is needed and when it fails here)

Bogumił Kamiński
  • 66,844
  • 3
  • 80
  • 107
  • You can also just do: `st` and it will give you all your packages and their versions. – logankilpatrick Dec 16 '20 at 14:15
  • 2
    `pathof` has been fixed for 1.6 so no need to jump through hoops with `methods` etc. In addition, you can use `pkgdir(DataFrames)`, which gives the package root folder. I would also advise against changing package environment in runtime. – fredrikekre Dec 16 '20 at 14:59
  • The 1.6 fix is great, bravo. I agree changing package environment at runtime is not advisable. The problem is that this is one of the most common root causes of issues I get reported regards how DataFrames.jl works. – Bogumił Kamiński Dec 16 '20 at 16:36