# Determine whether a project has been instantiated

**URL:** <https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652>\
**Category:** General Usage\
**Tags:** question, pkg, languageserver\
**Created:** [January 10, 2025, 6:08pm UTC](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652 "2025-01-10T18:08:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [January 10, 2025, 6:08pm UTC](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652/1 "2025-01-10T18:08:37Z")

</div>

Is it possible to determine whether a given folder containing a Julia project has been instantiated? The folder is unrelated to the `julia` process where I want to do this, i.e., I’m not trying to figure out whether the _current_ project has been instantiated, but some other project in some arbitrary folder.

This is in the context of [finding a project root for LanguageServer](https://github.com/goerz/neovimrc/blob/5d51214915cefb0e31ec8f22ba28f845aad404a6/helpers/julia_languageserver.jl#L23). I’ve been using the existence of a `Manifest.toml` or `JuliaManifest.toml` file as a proxy. One problem with that is that this doesn’t actually guarantee that the `Pkg.instantiate()` has been run. It’s only a good proxy because I typically don’t commit `Manifest.toml`, so these files only exist after instantiation.

Even if I’m happy to use the existence of manifest files as a relevant proxy, we now also have [version-dependent manifests](https://pkgdocs.julialang.org/v1/toml-files/#Different-Manifests-for-Different-Julia-versions). So I’m not quite sure about all the filenames I would have to check (is `JuliaManifest-v1.11.toml` supported?).

So, any recommendations for what might be the easist way to determine whether some given folder has been instantiated or not?

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [January 10, 2025, 9:49pm UTC](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652/2 "2025-01-10T21:49:22Z")

</div>

When you say `instantiate`d you also want to know whether every dependency has been precompiled? Or what is the point?

Either way I think the correct way is using functionality from Pkg.jl and I think it shouldn’t be too hard… if one knows how to do it 😅  
I think I would read the code of `Pkg.instantiate()` and all the necessary logic should be in there.

---

<div class="post-metadata">

**Author:** ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Post date:** [January 10, 2025, 10:16pm UTC](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652/3 "2025-01-10T22:16:47Z")

</div>

There isn’t anything off the shelf & public that I’m aware of, but this works with some internals

```julia
julia> import Pkg

julia> env = Pkg.Types.EnvCache("/Users/ian/.julia/environments/v1.11/Project.toml");

julia> Pkg.Operations.is_instantiated(env)
true

julia> all(name_uuid -> Base.isprecompiled(Base.PkgId(name_uuid[2], name_uuid[1])), env.project.deps)
false

```

The latter being if all Project deps are precompiled.

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [January 11, 2025, 12:46am UTC](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652/4 "2025-01-11T00:46:52Z")

</div>

> [@abraemer](#):
>
> what is the point?

My understanding is that `LanguageServer` requires that the project-folder has been instantiated, so that it can analyze all the packages in the environment. So the point is precisely that: to determine whether a given folder is suitable as a project-folder for `LanguageServer`. I’m not sure what that implies about whether packages have to be precompiled.

I might at some point go further in my wrapper script to say “if the project folder isn’t instantiated yet, run a subprocess with `Pkg.instantiate` to make sure that it is”. But we’ll see.

---

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [January 11, 2025, 12:30pm UTC](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652/5 "2025-01-11T12:30:05Z")

</div>

It would seem to me that if there are a Project.toml **and** a Manifest.toml in the folder, it 's instantiated. I don’t see how one creates these files without

```julia
instantiate .

```

---

<div class="post-metadata">

**Author:** ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)\
**Post date:** [January 11, 2025, 1:09pm UTC](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652/6 "2025-01-11T13:09:29Z")

</div>

Instantiate also check packages are downloaded to .julia/packages and necessary artifacts to .julia/artifacts. And possibly then precompiles the former.

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [January 11, 2025, 3:22pm UTC](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652/7 "2025-01-11T15:22:55Z")

</div>

> [@ctkelley](#):
>
> It would seem to me that if there are a Project.toml **and** a Manifest.toml in the folder, it 's instantiated.

You could commit the manifest, but then when you clone the repo, you still have to re-instantiate it (for `LanguageServer` to work, I think). If the manifest wasn’t committed, the yeah, the only issue would be reliably figuring out the name of the manifest file, which isn’t as simple as it used to be.
