How to add MyPkg to local registry?

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!

Start by looking into the LocalRegistry package.

4 Likes

I used this but I get an error…

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

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?

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.

2 Likes

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.

    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

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

    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.

1 Like

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

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