# What is the difference between Pkg.resolve and Pkg.instantiate?

**URL:** <https://discourse.julialang.org/t/what-is-the-difference-between-pkg-resolve-and-pkg-instantiate/77643>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 9, 2022, 5:22pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-pkg-resolve-and-pkg-instantiate/77643 "2022-03-09T17:22:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [March 9, 2022, 5:22pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-pkg-resolve-and-pkg-instantiate/77643/1 "2022-03-09T17:22:26Z")

</div>

The documentation for `resolve` and `instantiate` don’t explain this thoroughly.  
When is `Pkg.resolve` useful? I notice that `resolve` fails if there is no registry installed. Whereas `instantiate` will automatically install a missing registry.

The docs led me to believe, although they don’t say it explicitly, that `resolve` will only, possibly, compute and write a new `Manifest.toml`. But, in fact, if the depot is empty, it will download the packages, just like `instantiate`.

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [March 9, 2022, 7:48pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-pkg-resolve-and-pkg-instantiate/77643/2 "2022-03-09T19:48:41Z")

</div>

If you don’t have a Manifest.toml, then they’re equivalent. If you do, then:

- `instantiate` will download and precompile any packages that are listed in the Manifest.toml
- `resolve` will first check that the Manifest.toml is consistent with the Project.tomls of the current project and all its dependencies, updating it if necessary, then instantiate.
  - this is particularly useful during development: e.g. if you’re using a `dev`-ed dependency of a package and add a new dependency to it, then you need to go resolve your top project to make sure these changes are reflected in its Manifest

- `update` will use the newest possible dependencies (subject to compatibility constraints)

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 9, 2022, 8:26pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-pkg-resolve-and-pkg-instantiate/77643/3 "2022-03-09T20:26:44Z")

</div>

> [@jlapeyre](#):
>
> I notice that `resolve` fails if there is no registry installed

That seems like a bug to me.

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [March 9, 2022, 9:13pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-pkg-resolve-and-pkg-instantiate/77643/4 "2022-03-09T21:13:19Z")

</div>

Yes. If this is not correct:

doresolve.jl

```julia
import Pkg

mkdir("./newproj")
mkdir("./newdepot")
Pkg.activate("./newproj")
Pkg.add("Example")
rm("./newproj/Manifest.toml")
save_depot = copy(DEPOT_PATH)
empty!(DEPOT_PATH)
push!(DEPOT_PATH, abspath("./newdepot"))
Pkg.resolve()

```

```julia
julia> include("doresolve.jl")
  Activating new project at `~/resolvebug/newproj`
   Resolving package versions...
    Updating `~/resolvebug/newproj/Project.toml`
  [7876af07] + Example v0.5.3
    Updating `~/resolvebug/newproj/Manifest.toml`
  [7876af07] + Example v0.5.3
ERROR: LoadError: expected package `Example [7876af07]` to be registered

```

But starting again from scratch and using `instantiate` rather than `resolve` does work. In particular part of the output is ` Installing known registries into`~/resolvebug/newdepot``
