# How to add MyPkg to local registry?

**URL:** <https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [June 1, 2021, 11:56am UTC](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183 "2021-06-01T11:56:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Impressium](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/impressium/32/19575_2.png) [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Post date:** [June 1, 2021, 11:56am UTC](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183/1 "2021-06-01T11:56:11Z")

</div>

Hi all,

I work behind company walls and develop in Julia. I’m creating custom packages and want to register them locally. How would that work?

Thanks!

---

<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:** [June 1, 2021, 12:06pm UTC](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183/2 "2021-06-01T12:06:15Z")

</div>

Start by looking into the [LocalRegistry](https://github.com/GunnarFarneback/LocalRegistry.jl) package.

---

<div class="post-metadata">

**Author:** ![Impressium](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/impressium/32/19575_2.png) [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Post date:** [June 8, 2021, 8:35am UTC](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183/3 "2021-06-08T08:35:18Z")

</div>

I used this but I get an error…

```julia-auto
using LocalRegistry, Pkg
path = LocalRegistry.create_registry(
    "Trinity", # name_or_path
    "Trinity" # repo
)

# path = "C:\\Users\\<user>\\.julia\\registries\\Trinity"
spec = Pkg.RegistrySpec(path=path)
Pkg.Registry.add(spec) 
Pkg.Registry.status()

LocalRegistry.register(
    raw"C:\TrinityAPI\packages\julia\TrinityApi", 
    registry = "Trinity", 
    repo = raw"C:\TrinityAPI\packages\julia\TrinityApi"
) 

```

# Error

```julia-auto
HEAD is now at 3ce63e5 Create registry.
ERROR: failed process: Process(`git -C 'C:\Users\<user>\.julia\registries\Trinity' push`, ProcessExited(128)) [128]

Stacktrace:
 [1] pipeline_error
   @ .\process.jl:525 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base .\process.jl:440
 [3] run
   @ .\process.jl:438 [inlined]
 [4] do_register(package::String, registry::String; commit::Bool, push::Bool, repo::String, gitconfig::Dict{Any, Any})
   @ LocalRegistry C:\Users\<user>\.julia\packages\LocalRegistry\1yCRR\src\LocalRegistry.jl:212
 [5] #register#2
   @ C:\Users\<user>\.julia\packages\LocalRegistry\1yCRR\src\LocalRegistry.jl:136 [inlined]
 [6] top-level scope
   @ REPL[10]:1

```

What happens there?

---

<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:** [June 8, 2021, 9:12am UTC](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183/4 "2021-06-08T09:12:05Z")

</div>

> [@Impressium](#):
>
> ```julia
> path = LocalRegistry.create_registry(
> "Trinity", # name_or_path
> "Trinity" # repo
> )
> 
> ```

The `repo` argument needs to be a `git` URL to a remote repository, e.g. on Github or on a company git server. You can use LocalRegistry without having a valid `repo` URL but in that case you need to add the keyword argument `push=false` to the `register` call.

Similarly the `repo` argument to `register` should be a `git` URL where Pkg can find your package when you’re using your registry.

---

<div class="post-metadata">

**Author:** ![Impressium](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/impressium/32/19575_2.png) [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Post date:** [June 8, 2021, 12:09pm UTC](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183/5 "2021-06-08T12:09:13Z")

</div>

Now almost everything is working. But if I update a packages the julia pkg repl doesn’t get it updated. I use `up MyPkg` and get the following error.

```julia
    Updating git-repo `Trinity`
┌ Warning: Some registries failed to update:
│ — C:\Users\<user>\.julia\registries\Trinity — failed to fetch from repo
└ @ Pkg.Types C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Types.jl:1229

```

---

<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:** [June 8, 2021, 1:11pm UTC](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183/6 "2021-06-08T13:11:41Z")

</div>

I’m a bit lost on what you actually have done at this point and what you expect to happen but

```julia
    Updating git-repo `Trinity`

```

will keep failing until you you create your registry with a valid `git` URL to a remote repository. If you only want to use your registry with that installation of Julia and not share it in anyway you can just ignore the warning.

---

<div class="post-metadata">

**Author:** ![Impressium](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/impressium/32/19575_2.png) [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Post date:** [June 9, 2021, 7:09am UTC](https://discourse.julialang.org/t/how-to-add-mypkg-to-local-registry/62183/7 "2021-06-09T07:09:18Z")

</div>

I got it now. I had to register very new version. So after I updated the version auf `MyPkg` I needed to rerun:

```julia
LocalRegistry.register(
    raw"C:\TrinityAPI\packages\julia\MyPkg", 
    registry = "Trinity", 
    repo = raw"C:\TrinityAPI\packages\julia\MyPkg",
    push = false
) 

```
