LocalRegistry.jl: is `master` branch required?

I decided to try using LocalRegistry.jl for some private packages we have. I created a registry and added one package to it, and that appears to have pushed correctly. However, trying to use it doesn’t appear to be working. Is it because my repo’s main branch is called main rather than master? Here’s how things went down.

I created LocalRegistryTest in GitHub as a bare repo. By default now, the main branch is main.

Back over here on my local machine, I ran:

julia> using LocalRegistry
julia> create_registry("LocalRegistryTest", "git@github.com:tuckermcclure/LocalRegistryTest.git", description = "A test registry in Tucker's personal GitHub")

I have SSH keys set up so private repo stuff all just works.

I have a package called EulerParameters. I have it checked out locally, so I navigated there, activated it, imported it, and registered it:

cmd> julia --project=.
julia> using EulerParameters
julia> register(EulerParameters, branch = "main")
┌ Info: Registering package
│   package_path = "/Users/tucker/Dev/EulerParameters.jl"
│   registry_path = "/Users/tucker/.julia/registries/LocalRegistryTest"
│   package_repo = "git@github.com:[redacted]/EulerParameters.jl.git"
│   uuid = UUID("7d4c595f-83da-47b2-93f6-2989baeee392")
│   version = v"0.1.0"
│   tree_hash = "cbece3366d59efdf532e84d24a1e3391a82a2d1b"
└   subdir = ""
Switched to a new branch 'main'
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 10 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (12/12), 1.25 KiB | 1.25 MiB/s, done.
Total 12 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), done.
To github.com:tuckermcclure/LocalRegistryTest.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.
Switched to branch 'master'
warning: deleting branch 'main' that has been merged to
         'refs/remotes/origin/main', but not yet merged to HEAD.
Deleted branch main (was 2ecd1c3).

That “switched to branch ‘master’” part made me a bit nervous. Just to try it out though, I started a new project somewhere and tried to add EulerParameters.

(@v1.8) pkg> activate .
  Activating new project at `~/whatever`

(whatever) pkg> add EulerParameters
    Updating registry at `~/.julia/registries/LocalRegistryTest`
    Updating git-repo `git@github.com:tuckermcclure/LocalRegistryTest.git`
    Updating registry at `~/.julia/registries/General.toml`
┌ Error: Some registries failed to update:
│     — /Users/tucker/.julia/registries/LocalRegistryTest — branch origin/master not found
└ @ Pkg.Registry /Users/administrator/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-aarch64-1.0/build/default-macmini-aarch64-1-0/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/Pkg/src/Registry/Registry.jl:449
ERROR: The following package names could not be resolved:
 * EulerParameters (not found in project, manifest or registry)

That “branch origin/master not found” part leaves me wondering if the name master is baked in somewhere. Did I miss a configuration step? Must the main branch be master? Thank you for any help! I’m trying to get to a “proper” workflow for private repos in an organization.

I’ve fixed the problem, but I’m still wondering how I ought to have done things from scratch to avoid the problem.

To fix it, I removed the registry and added it from its URL. Now it knows to use the main branch.

pkg> registry rm LocalRegistryTest
pkg> registry add git@github.com:tuckermcclure/LocalRegistryTest.git

Now my registry works like expected. I was able to register new packages and have those just work for a new project.

Is there a way for create_registry to create the repo with the right branch? Maybe part of the gitconfig input? I don’t see any examples using that, and giving it a shot, it fails when I try give it flags for the initial branch name (like gitconfig = Dict("--initial-branch" => "main")).

I’d be happy to help contribute a doc example of the right way to do this once I figure it out!

As far as I’m concerned this is not a documentation problem but something that should just work. The best way to help would be to find how to reproduce this on local disk without involving GitHub, probably by doing a git init in the right way to simulate the upstream GitHub repository and pointing to it with a file:// URL.

I made what I believe are the correct changes and put up a draft pull request. It uses the initial-branch option in git, though possibly it should switch to a method with better backwards compatibility. However, I went ahead and posted this so I could get your feedback. It works correctly when I test against local repos, as you suggest.

1 Like