# Building and precompiling a package depending on unregistered packages

**URL:** https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955
**Category:** General Usage
**Tags:** question, package, build, precompilation, dependency-issue
**Created:** [July 23, 2023, 10:18am UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955 "2023-07-23T10:18:41Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Matthew\_Ozon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matthew_ozon/32/43189_2.png) [@Matthew\_Ozon](https://discourse.julialang.org/u/Matthew_Ozon)
#### Post date: [July 23, 2023, 10:18am UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955/1 "2023-07-23T10:18:41Z")

</div>

When testing a local package X, some issues appear while `build`-ing and `precompile`-ing.  
The reason for that is the unregistered packages in the dependency tree.  
The unregistered packages (Y and Z) are installed locally from their respective github repositories (at url\_Y and url\_Z), and they are functional (at least locally on my computer).

If I try to build package X that depends on the unregistered packages Y and Z using my Project.toml file:

```julia
name = "X"
uuid = "uuid_X"
version = "0.0.0"

[deps]
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Y = "uuid_Y"
Z = "uuid_Z" 

[compat]
julia = "1"

[where]
Y = "url_Y"
Z = "url_Z"

```

Then, I get the following error message

```julia
Updating registry at `~/.julia/registries/General.toml`
ERROR: expected package `Y [tag_Y]` to be registered

```

and no Manifest.toml file is created.  
So, to go around this issue, I comment out the unregistered packages under the [deps] and [where] tags.  
Then I can build the package to create the Manisfet file, but of course I cannot `precompile` since there are missing dependencies.  
Now, I add manually to the Manifest.toml the missing dependencies

```julia
[[deps.Y]]
git-tree-sha1 = "gts_Y"
repo-rev = "master"
repo-url = "url_Y"
uuid = "uuid_Y"
version = "0.0.0"

[[deps.Z]]
git-tree-sha1 = "gts_Z"
repo-rev = "main"
repo-url = "url_Z"
uuid = "uuid_Z"
version = "0.0.0"

```

and uncomment the commented lines in the Project.toml file.  
Finally, running `resolve` rearranges the manifest and I can `precompile` package X (and test it locally).

I know it’s a very specific issue for when you want to use unregistered packages, but wouldn’t it be possible to add a functionality to `build` so that it can deal with unregistered packages? (or is it already a functionality and I’ve completely missed it? Not impossible at all)

Julia version 1.8.3

---

<div class="post-metadata">

### Author: ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)
#### Post date: [July 23, 2023, 10:56am UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955/2 "2023-07-23T10:56:24Z")

</div>

As far as I understand it’s not possible to resolve unregistered packages with a project file alone.  
I never heard of a `where` entry in the Project.toml and you should always ship/send/copy both project and manifest files when depending on unregistered package versions.

You don’t have to modify the manifest file manually yourself though, you can add unregistered versions either with `Pkg.add` or `Pkg.develop` (or their respective calls using the Pkg REPL mode) and the manifest file will be correctly generated for you.

You then have to simply copy it in the new location/computer you want to build the environment

---

<div class="post-metadata">

### Author: ![Matthew\_Ozon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matthew_ozon/32/43189_2.png) [@Matthew\_Ozon](https://discourse.julialang.org/u/Matthew_Ozon)
#### Post date: [July 23, 2023, 11:29am UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955/3 "2023-07-23T11:29:23Z")

</div>

thanks for the response.

I didn’t mention, but the unregistered packages were installed from the REPL using `] add` .

I’ve just tried to `dev` the packages, but I still get the error message at `build`-ing time

```julia
expected package `Y [tag_Y]` to be registered

```

No manifest is created at that point

---

<div class="post-metadata">

### Author: ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)
#### Post date: [July 23, 2023, 11:38am UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955/4 "2023-07-23T11:38:15Z")

</div>

Did you add the packages using a path rather than a name? Even for packages located directly as a subfolder of the current position you have to add specifiying the path with a dot.

So if you are in a folder containing the package folder Y, you should do `add ./Y` and not simply `add Y`

If you don’t specify a path it will always try to fetch a package with that name in the available registries.

If you try to add a local package just by its name I seem to remember the repl gives you a warning to tell you about this

---

<div class="post-metadata">

### Author: ![Matthew\_Ozon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matthew_ozon/32/43189_2.png) [@Matthew\_Ozon](https://discourse.julialang.org/u/Matthew_Ozon)
#### Post date: [July 23, 2023, 11:42am UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955/5 "2023-07-23T11:42:21Z")

</div>

I added the packages with the url of the repo `add url_Y`

I’ll test with the local path and see if it helps in my case

---

<div class="post-metadata">

### Author: ![Matthew\_Ozon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matthew_ozon/32/43189_2.png) [@Matthew\_Ozon](https://discourse.julialang.org/u/Matthew_Ozon)
#### Post date: [July 23, 2023, 12:35pm UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955/6 "2023-07-23T12:35:45Z")

</div>

Again, I didn’t mention that I had `activate`-ed the X-package project (`activate /path/to/package/X/`), which seems to make the difference.

So, I removed the packages Y and Z, and re-install them from the github repository.

I’ve updated the Project.toml (no more `[where]` tag)

```julia
name = "X"
uuid = "uuid_X"
version = "0.0.0"

[deps]
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Y = "uuid_Y"
Z = "uuid_Z" 

[compat]
julia = "1"

```

Then, I locally `dev` the package X (`dev /path/to/package/X/`) and that’s it. I can `build` and `precompile` the package X.  
I guess when I `activate`-ed project X, the unregistered packages could not be seen, maybe?

Thanks for your help @disberd

---

<div class="post-metadata">

### Author: ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)
#### Post date: [July 23, 2023, 12:40pm UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955/7 "2023-07-23T12:40:53Z")

</div>

I find a [LocalRegistry](https://github.com/GunnarFarneback/LocalRegistry.jl) the most convenient approach.

---

<div class="post-metadata">

### Author: ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)
#### Post date: [July 23, 2023, 12:41pm UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955/8 "2023-07-23T12:41:05Z")

</div>

Know that if you activate a package environment (X in your case) you don’t have to dev X again.  
When you are inside a package environment (inside as in you activated it) you can just do `using X` without having to add it. And if you are using Revise it will update changes in your source files of X

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [July 23, 2023, 1:35pm UTC](https://discourse.julialang.org/t/building-and-precompiling-a-package-depending-on-unregistered-packages/101955/9 "2023-07-23T13:35:53Z")

</div>

`Pkg.add` requires a git repository. The location of the git repo will be recorded in the Manifest.toml if not in a registry.
