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

**URL:** https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242
**Category:** General Usage
**Tags:** package
**Created:** [September 27, 2019, 5:58pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242 "2019-09-27T17:58:23Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![steph\_de\_paris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steph_de_paris/32/7780_2.png) [@steph\_de\_paris](https://discourse.julialang.org/u/steph_de_paris)
#### Post date: [September 27, 2019, 5:58pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/1 "2019-09-27T17:58:23Z")

</div>

Hello,

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

`Pkg.add("xxx@1.2.3")`

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

Thanks very much for your help !

---

<div class="post-metadata">

### Author: ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)
#### Post date: [September 27, 2019, 5:59pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/2 "2019-09-27T17:59:43Z")

</div>

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](https://julialang.github.io/Pkg.jl/dev/api/#Pkg.add)

---

<div class="post-metadata">

### Author: ![steph\_de\_paris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steph_de_paris/32/7780_2.png) [@steph\_de\_paris](https://discourse.julialang.org/u/steph_de_paris)
#### Post date: [September 27, 2019, 6:21pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/3 "2019-09-27T18:21:36Z")

</div>

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  
I **nstalled 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.** ☹

Is-it the case ? If yes, why ?

---

<div class="post-metadata">

### Author: ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)
#### Post date: [September 27, 2019, 6:59pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/4 "2019-09-27T18:59:14Z")

</div>

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

---

<div class="post-metadata">

### Author: ![steph\_de\_paris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steph_de_paris/32/7780_2.png) [@steph\_de\_paris](https://discourse.julialang.org/u/steph_de_paris)
#### Post date: [September 27, 2019, 7:00pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/5 "2019-09-27T19:00:23Z")

</div>

julia\> VERSION  
v"1.0.0"

---

<div class="post-metadata">

### Author: ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)
#### Post date: [September 27, 2019, 7:06pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/6 "2019-09-27T19:06:22Z")

</div>

Yea the bug is present in that version. I suggest you update to the latest LTS version or the latest stable version: [Download Julia](https://julialang.org/downloads/).

---

<div class="post-metadata">

### Author: ![steph\_de\_paris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steph_de_paris/32/7780_2.png) [@steph\_de\_paris](https://discourse.julialang.org/u/steph_de_paris)
#### Post date: [September 27, 2019, 7:25pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/7 "2019-09-27T19:25:57Z")

</div>

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

---

<div class="post-metadata">

### Author: ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)
#### Post date: [September 27, 2019, 7:27pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/8 "2019-09-27T19:27:28Z")

</div>

Yes

---

<div class="post-metadata">

### Author: ![steph\_de\_paris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steph_de_paris/32/7780_2.png) [@steph\_de\_paris](https://discourse.julialang.org/u/steph_de_paris)
#### Post date: [September 27, 2019, 7:31pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/9 "2019-09-27T19:31:22Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [November 18, 2022, 3:47pm UTC](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242/10 "2022-11-18T15:47:27Z")

</div>

> [@00vareladavid](#):
>
> Sure, that would be `Pkg.add(Pkg.PackageSpec(;name="xxx", version="1.2.3"))`

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

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

```
