# Newcomer's guide to Julia package manager

**URL:** <https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492>\
**Category:** General Usage\
**Tags:** package, documentation\
**Created:** [January 17, 2020, 2:55pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492 "2020-01-17T14:55:27Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaowens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaowens/32/12101_2.png) [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Post date:** [January 17, 2020, 2:55pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/1 "2020-01-17T14:55:27Z")

</div>

I wrote a blog post to help beginners understand package management in Julia. The intended audience is people who have no familiarity with the concept of packages, versions, etc. I’ve seen a lot of people try to run some Julia code they found somewhere and not understand why it doesn’t just work. This is understandable coming from MATLAB or Stata where this usually isn’t a problem.

To address this, I walk through an example where code fails to run due to some package issue, then suggest how they can solve this by using environments. I recommend using project specific environments for everything, which is admittedly not how I used to do things, but makes sharing and archiving your code much easier and prevents version conflicts.

Comments welcome!

> **[A Newcomers Guide To The Julia Package Manager](https://aaowens.github.io/julia/2020/01/13/A-Newcomers-Guide-to-the-Julia-Package-Manager.html)**
>
> NOTE: Some of this code, specifically the pkg"..." strings, is only compatible with Julia 1.3 and later. I recommend upgrading to Julia 1.3.1 if you haven’t already; it’s quite a bit faster at some things.

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [January 17, 2020, 4:06pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/2 "2020-01-17T16:06:27Z")

</div>

This is great. I hope you work on something similar for package developers and how to use `dev` in combination with environments. This stuff always gets me confused.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [January 17, 2020, 4:34pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/3 "2020-01-17T16:34:42Z")

</div>

Trying this out with Julia 1.1 and I get this error with `using GLM`.

```julia
julia> using GLM
[Info: Recompiling stale cache file /Users/peterdeffebach/.julia/compiled/v1.1/GLM/6OREG.ji for GLM [38e38edf-8417-5370-95a0-9cbb8c7f171a]
ERROR: LoadError: Unable to import Arpack_jll on Julia versions older than 1.3!

```

I think you actually _need_ 1.3 to run this code, not just that it’s recommended. Do you need Julia version bounds in your project.toml?

edit: an `] up` in the same environment fixed it. But still less than ideal for a new comer to julia used to just `ssc` install-ing until the code runs.

---

<div class="post-metadata">

**Author:** ![aaowens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaowens/32/12101_2.png) [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Post date:** [January 17, 2020, 4:50pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/4 "2020-01-17T16:50:23Z")

</div>

I recommend @ChrisRackauckas’s [video](https://www.youtube.com/watch?v=QVmU29rCjaA&t=2309s) for package development. He says in the video comments

> Note: After "]dev"ing a package, the local version of “using Package” uses the package in your “~/.julia/dev/Package” folder!

I don’t actually know how `dev` interacts with environments. My guess is that if you run `dev` in a local project environment, it would update the manifest to point to the dev version, but I’m not sure. It’s a good question.

---

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [January 17, 2020, 4:59pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/5 "2020-01-17T16:59:43Z")

</div>

> [@aaowens](#):
>
> I don’t actually know how `dev` interacts with environments. My guess is that even if run `dev` in a local project environment, it would update the manifest to point to the dev version, but I’m not sure. It’s a good question.

Indeed that is what it does, the Manifest will point to the dev’ed path and it is your responsibility to manage that until you free the package.

---

<div class="post-metadata">

**Author:** ![aaowens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaowens/32/12101_2.png) [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Post date:** [January 17, 2020, 5:00pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/6 "2020-01-17T17:00:48Z")

</div>

Good point! I hadn’t realized the latest version of GLM was 1.3 only. The advice still works, but that particular example with that Manifest.toml won’t work.

That being said, I really do recommend 1.3. It’s a lot more pleasant to work with environments in 1.3 because of [https://github.com/JuliaLang/julia/pull/32651](https://github.com/JuliaLang/julia/pull/32651) which stops repeated precompiles when swapping between environments – at least, that is my understanding of what that PR does.

edit: @pdeffebach I fixed this by creating the Manifest.toml on 1.2 and updating the zip file. It should work on earlier versions now. I tested on 1.1.1 and 1.3.

---

<div class="post-metadata">

**Author:** ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)\
**Post date:** [January 17, 2020, 10:44pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/7 "2020-01-17T22:44:32Z")

</div>

@aaowens Thanks for doing this! I have a noob question, I know you can leave an environment by calling `] activate` without the dot at the end. And you can come back to it later. However, when you return to an environment, do you have to do both

```julia
] activate .
] instantiate

```

If not, what do you need `instantiate` for?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [January 17, 2020, 11:30pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/8 "2020-01-17T23:30:19Z")

</div>

As the documentation says, `instantiate`is responsible for: " If a `Manifest.toml` file exist in the current project, download all the packages declared in that manifest. Else, resolve a set of feasible packages from the `Project.toml` files and install them."

In other words, when a new environment is activated, it needs to be populated by the required packages.  
My guess is when switching to the default environment, there is no need for instantiation. I believe it is a no-op in that case.

---

<div class="post-metadata">

**Author:** ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)\
**Post date:** [January 17, 2020, 11:33pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/9 "2020-01-17T23:33:49Z")

</div>

That’s what I thought. So, you `instantiate` in case there’s an environment you want to replicate, but if you’re just working on an environment, `activate .` is enough.

---

<div class="post-metadata">

**Author:** ![Wenjie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wenjie/32/10123_2.png) [@Wenjie](https://discourse.julialang.org/u/Wenjie)\
**Post date:** [January 18, 2020, 11:14am UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/10 "2020-01-18T11:14:40Z")

</div>

I was not aware that Pkg has now its own website. Is there any other documentation extracted from the Julia docs?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 18, 2020, 4:31pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/11 "2020-01-18T16:31:22Z")

</div>

I think it is the other way round: the `Pkg` docs were not extracted from the manual, a [brief summary](https://docs.julialang.org/en/v1/stdlib/Pkg/) was _incorporated_ into the manual instead. Which of course links to the actual Pkg manual.

---

<div class="post-metadata">

**Author:** ![Wenjie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wenjie/32/10123_2.png) [@Wenjie](https://discourse.julialang.org/u/Wenjie)\
**Post date:** [January 21, 2020, 1:31am UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/12 "2020-01-21T01:31:10Z")

</div>

The manual in its current form is just the “get started” page of the whole Pkg docs, but in the past it was a very long, exhausting page.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 21, 2020, 7:23am UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/13 "2020-01-21T07:23:40Z")

</div>

Yes, but that was a different package manager.

---

<div class="post-metadata">

**Author:** ![David\_Mc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/david_mc/32/10191_2.png) [@David\_Mc](https://discourse.julialang.org/u/David_Mc)\
**Post date:** [January 21, 2020, 2:30pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/14 "2020-01-21T14:30:32Z")

</div>

Thanks for the post, pkg management has been a bit of a struggle for me.

Would you have something similar for all of us who are working on **non-networked systems**?

---

<div class="post-metadata">

**Author:** ![aaowens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aaowens/32/12101_2.png) [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Post date:** [January 21, 2020, 9:12pm UTC](https://discourse.julialang.org/t/newcomers-guide-to-julia-package-manager/33492/15 "2020-01-21T21:12:27Z")

</div>

I don’t have any experience with that. A Docker image with packages pre-installed would work.
