# How to use the PackageCompiler with a private registry

**URL:** https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732
**Category:** General Usage
**Tags:** package-compiler
**Created:** [July 15, 2025, 8:27am UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732 "2025-07-15T08:27:06Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [July 15, 2025, 8:27am UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732/1 "2025-07-15T08:27:06Z")

</div>

I have the following structure:

```julia
├──App/
├──compiled/
│ ├── make.jl
│ ├── precompile.jl
├──deps/
├──Project.toml

```

where `make.jl` is

```julia
using PackageCompiler

PackageCompiler.create_app(
    "App",
    "compiled/App";
    cpu_target="generic",
    sysimage_build_args=`-O3`,
    precompile_execution_file="compiled/precompile.jl",
    include_transitive_dependencies=false,
    include_lazy_artifacts=true,
    incremental=true,
)

```

and `precompile.jl` runs some exemplary workload

```julia
import App
import JSON

App.run()
# something else

```

In my root `Project.toml` i have only `PackageCompiler.jl` as dependency.  
And in my `App` I have some dependencies, including local modules via `[sources]` and packages from a private registry.

When I run `include("compiled/make.jl")` I get an error message that one of the private packages is not registered. `ERROR: expected package .... to be registered`

In my `App` I also have tests which run fine.

---

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [July 15, 2025, 12:01pm UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732/2 "2025-07-15T12:01:34Z")

</div>

In `Pkg.Registry.reachable_registries()` I see my registry.

And with debug enabled I see:

```julia
...
  Total artifact file size: 35.037 MiB
┌ Debug: instantiating project at "C:\\<path-to-project>\\App"
└ @ PackageCompiler C:\JuliaPackages\packages\PackageCompiler\cTtGY\src\PackageCompiler.jl:582
┌ Debug: ensurecompiled: running `'C:\Julia_newest\bin\julia.exe' --color=yes --startup-file=no --pkgimages=no '--sysimage=C:\Julia_newest\lib\julia\sys.dll' -e 'using Pkg; Pkg.precompile()'`
│ JULIA_LOAD_PATH = "C:\\<path-to-project>\\App;@stdlib"
└ @ PackageCompiler C:\JuliaPackages\packages\PackageCompiler\cTtGY\src\PackageCompiler.jl:298
    Updating registry at `C:\<user-path>\.julia\registries\General.toml`
ERROR: expected package `MyPackage [6c6c7b4e]` to be registered

```

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [July 15, 2025, 1:24pm UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732/3 "2025-07-15T13:24:07Z")

</div>

> [@ohmsweetohm1](#):
>
> ```julia
> └ @ PackageCompiler C:\JuliaPackages\packages\PackageCompiler\cTtGY\src\PackageCompiler.jl:298
> Updating registry at `C:\<user-path>\.julia\registries\General.toml`
> ERROR: expected package `MyPackage [6c6c7b4e]` to be registered
> 
> ```

I would have expected a line `Updating registry at...` for your private registry as well, so it doesn’t look like PackageCompiler is seeing the same registries as you are.

I’m regularly using PackageCompiler with a private registry at work without problems, but a difference is that we run our own package server, which makes Pkg install our private registry by default.

I have tried to disable the package server in order to reproduce this problem, without success, but I can’t say with confidence that I managed to set up a correct environment.

---

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [July 15, 2025, 3:52pm UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732/4 "2025-07-15T15:52:49Z")

</div>

That is interesting.  
Could you elaborate on how you do that?  
I guess you are using this: [GitHub - GunnarFarneback/LocalPackageServer.jl: Julia storage and package server for local packages.](https://github.com/GunnarFarneback/LocalPackageServer.jl)

---

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [July 15, 2025, 3:56pm UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732/5 "2025-07-15T15:56:01Z")

</div>

I tried with replacing the `get_julia_cmd` method to include a startup file and installing the registry.

```julia
function PackageCompiler.get_julia_cmd()
    julia_path = joinpath(Sys.BINDIR, Base.julia_exename())
    color = if Base.have_color === nothing
        "auto"
    elseif Base.have_color
        "yes"
    else
        "no"
    end
    if isdefined(Base, :Linking) # pkgimage support feature flag
        `$julia_path --color=$color --startup-file=yes --pkgimages=no`
    else
        `$julia_path --color=$color --startup-file=yes`
    end
end

```

But I get now a different error:

```julia
Cloning registry from "<url-to-my-registry>MyRegistry.jl.git"
Registry `MyRegistry` already exists in `C:\<path>\registries\MyRegistry`.
ERROR: Precompiling failed to find source of parent package: "MyPackage" project...

```

---

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [July 15, 2025, 4:01pm UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732/6 "2025-07-15T16:01:28Z")

</div>

I also tried to locally clone and `dev` the package. That works, however is not really feasible, since versioning does not work or is at least cumbersome.

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [July 15, 2025, 4:42pm UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732/7 "2025-07-15T16:42:46Z")

</div>

> [@ohmsweetohm1](#):
>
> In `Pkg.Registry.reachable_registries()` I see my registry.

Just checking for an unlikely mismatch, what does `Pkg.Registry.status()` say in the same scope where you would evaluate `include("compiled/make.jl")`?

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [July 15, 2025, 7:49pm UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732/8 "2025-07-15T19:49:49Z")

</div>

> [@ohmsweetohm1](#):
>
> I guess you are using this: [GitHub - GunnarFarneback/LocalPackageServer.jl: Julia storage and package server for local packages.](https://github.com/GunnarFarneback/LocalPackageServer.jl)

Spot on.

---

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [July 16, 2025, 9:52am UTC](https://discourse.julialang.org/t/how-to-use-the-packagecompiler-with-a-private-registry/130732/9 "2025-07-16T09:52:08Z")

</div>

I did set the `JULIA_DEPOT_PATH` in my startup file. Since the default build command used in PackageCompiler.jl does not use it the registry and the packages could not be found.  
There is a `Pkg.instantiate` but that is in the calling environment with the calling Julia, including the startup file. The actual `ensurecompiled` runs a bare Julia. Hence the problem.

Solution was to not set the `JULIA_DEPOT_PATH` in the startup file.
