How to install a specific version of a package with Pkg.add("...")


I know that is is possible to install a specific version of a package with

pkg> add xxx@1.2.3 (for example) in the julia> window.

Nevertheless, is-it possible to do this with something like


in a julia file, that is to say without using the previous julia window ?

Thanks very much for your help !


Sure, that would be Pkg.add(Pkg.PackageSpec(;name="xxx", version="1.2.3"))

You can see some more examples here: 12. API Reference Β· Pkg.jl


Thanks, it seems to work ! But, when I instal the CSV v0.5.9 (instead of CSV v0.5.12) AND the DataFrames packages, I obtain during the installation of the CSV package:

Installed CSV ───────────────────────── v0.5.9

which is OK.

But, during the installation of the DataFrames package, I obtain:

Resolving package versions…
Installed CategoricalArrays ─ v0.6.0
Installed CSV ─────────────── v0.5.12
Updating xxx/environments/v1.0/Project.toml
[336ed68f] ↑ CSV v0.5.9 β‡’ v0.5.12
[a93c6f00] + DataFrames v0.19.4
Updating xxx/environments/v1.0/Manifest.toml
[336ed68f] ↑ CSV v0.5.9 β‡’ v0.5.12
[324d7699] ↑ CategoricalArrays v0.5.5 β‡’ v0.6.0

And when I check with a status, I obtain:

[336ed68f] CSV v0.5.12
[a93c6f00] DataFrames v0.19.4

Thus, it seems that the installation of the CSV v0.5.9 has been canceled and that I came back to the CSV v0.5.12 version. :frowning:

Is-it the case ? If yes, why ?

This doesn’t seem like the correct behavior. What version of julia is this? (You can check by printing the VERSION variable)

julia> VERSION

Yea the bug is present in that version. I suggest you update to the latest LTS version or the latest stable version: Download Julia.

Do you mean that the problem discribed above would be corrected with the v1.2.0 ?


OK. In fact, I try to use an old CSV package because with the new version of the CSV package (v0.5.12) with the Julia-v1.0.0, I saw memory leak that I have treated with success with the garbage collector gc. Nevertheless, I would prefer not to use the gc. Thus, do you think that this RAM memory problem is in fact linked to the Juliav1.0.0 and NOT to the CSV package ?

in the current version of Pkg, it is not necessary to use the function Pkg.PackageSpec(), it is sufficient to write:

Pkg.add(name="PackageName", version="0.4.28")