Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no Registry.toml file in source directory. #57

Closed
musm opened this issue Apr 5, 2022 · 1 comment
Closed

no Registry.toml file in source directory. #57

musm opened this issue Apr 5, 2022 · 1 comment

Comments

@musm
Copy link

musm commented Apr 5, 2022

mkdir ~/TestLocalRegistry
cd ~/TestLocalRegistry
git init --bare

julia
julia> using Pkg, LocalRegistry
julia> create_registry("TestLocalRegistry", "~/TestLocalRegistry", description = "Test private registry", push=true)

julia> pkg"registry add ~/TestLocalRegistry"
     Copying registry from `~/numerica/NumericaRegistry2`
ERROR: no `Registry.toml` file in source directory.
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types ~/.julia/juliaup/julia-1.8.0-beta3+0~x64/share/julia/stdlib/v1.8/Pkg/src/Types.jl:67
  [2] (::Pkg.Registry.var"#39#41"{Base.TTY, String, Pkg.Registry.RegistrySpec, Nothing})(tmp::String)
    @ Pkg.Registry ~/.julia/juliaup/julia-1.8.0-beta3+0~x64/share/julia/stdlib/v1.8/Pkg/src/Registry/Registry.jl:214
  [3] mktempdir(fn::Pkg.Registry.var"#39#41"{Base.TTY, String, Pkg.Registry.RegistrySpec, Nothing}, parent::String; prefix::String)
    @ Base.Filesystem ./file.jl:764
  [4] mktempdir(fn::Function, parent::String) (repeats 2 times)
    @ Base.Filesystem ./file.jl:762
  [5] download_registries(io::Base.TTY, regs::Vector{Pkg.Registry.RegistrySpec}, depot::String)
    @ Pkg.Registry ~/.julia/juliaup/julia-1.8.0-beta3+0~x64/share/julia/stdlib/v1.8/Pkg/src/Registry/Registry.jl:191
  [6] download_registries
    @ ~/.julia/juliaup/julia-1.8.0-beta3+0~x64/share/julia/stdlib/v1.8/Pkg/src/Registry/Registry.jl:163 [inlined]
  [7] add(regs::Vector{Pkg.Registry.RegistrySpec}; io::Base.TTY)
    @ Pkg.Registry ~/.julia/juliaup/julia-1.8.0-beta3+0~x64/share/julia/stdlib/v1.8/Pkg/src/Registry/Registry.jl:49
  [8] add(regs::Vector{Pkg.Registry.RegistrySpec})
    @ Pkg.Registry ~/.julia/juliaup/julia-1.8.0-beta3+0~x64/share/julia/stdlib/v1.8/Pkg/src/Registry/Registry.jl:46
  [9] do_cmd!(command::Pkg.REPLMode.Command, repl::Pkg.REPLMode.MiniREPL)
    @ Pkg.REPLMode ~/.julia/juliaup/julia-1.8.0-beta3+0~x64/share/julia/stdlib/v1.8/Pkg/src/REPLMode/REPLMode.jl:409
 [10] do_cmd(repl::Pkg.REPLMode.MiniREPL, input::String; do_rethrow::Bool)
    @ Pkg.REPLMode ~/.julia/juliaup/julia-1.8.0-beta3+0~x64/share/julia/stdlib/v1.8/Pkg/src/REPLMode/REPLMode.jl:387
 [11] top-level scope
    @ REPL[29]:1
@GunnarFarneback
Copy link
Owner

I believe registry add with a path argument expects the path to contain the files of a registry. If you want the path to be treated as a git repository you have to encode it as a url:

pkg"registry add file:///home/XXX/TestLocalRegistry"

(You also need to remove the copy of the registry that was installed when you ran create_registry in order to test this.)

Some of the package tests might be of interest, e.g.

# Test automatic push functionality. The sequence of events is:
# 1. Create a bare "upstream" repository.
# 2. Create a new registry with the upstream as repo and `push = true`.
# 3. Register a package with `push = true`.
# 4. Verify that the registry and the upstream repo has the same two commits.
with_testdir() do testdir
upstream_dir = joinpath(testdir, "upstream")
mkpath(upstream_dir)
upstream_git = gitcmd(upstream_dir, TEST_GITCONFIG)
run(`$(upstream_git) init --bare`)
registry_push_dir = joinpath(testdir, "TestRegistryPush")
create_registry(registry_push_dir, "file://$(upstream_dir)", push = true,
gitconfig = TEST_GITCONFIG)
downstream_git = gitcmd(registry_push_dir, TEST_GITCONFIG)
packages_dir = joinpath(testdir, "packages")
prepare_package(packages_dir, "FirstTest1.toml")
register(joinpath(packages_dir, "FirstTest"), registry = registry_push_dir,
push = true, gitconfig = TEST_GITCONFIG)
@test readchomp(`$(downstream_git) log`) == readchomp(`$(upstream_git) log`)
@test length(readlines(`$(upstream_git) log --format=oneline`)) == 2
# Now duplicate the upstream repo. Then register the same package
# * like before via downstream repo with push,
# * directly against the second upstream, internally using a
# temporary clone.
upstream2_dir = joinpath(testdir, "upstream2")
mkpath(upstream2_dir)
upstream2_git = gitcmd(upstream2_dir, TEST_GITCONFIG)
run(`$(upstream2_git) clone --bare file://$(upstream_dir) .`)
prepare_package(packages_dir, "Flux1.toml")
register(joinpath(packages_dir, "Flux"), registry = registry_push_dir,
push = true, gitconfig = TEST_GITCONFIG)
# Can't have `push = false` when using a temporary git clone.
@test_throws ErrorException register(joinpath(packages_dir, "Flux"),
registry = "file://$(upstream2_dir)",
push = false,
gitconfig = TEST_GITCONFIG)
register(joinpath(packages_dir, "Flux"), registry = "file://$(upstream2_dir)",
push = true, gitconfig = TEST_GITCONFIG)
@test readchomp(`$(downstream_git) log`) == readchomp(`$(upstream_git) log`)
# Can't use standard log format here since the time stamps will be different.
@test readchomp(`$(downstream_git) log --format=%T:%s`) == readchomp(`$(upstream2_git) log --format=%T:%s`)
@test length(readlines(`$(upstream2_git) log --format=%T:%s`)) == 3
# Register one more package, this time using a branch.
prepare_package(packages_dir, "Images1.toml")
register(joinpath(packages_dir, "Images"), registry = registry_push_dir,
push = true, branch = "images", gitconfig = TEST_GITCONFIG)
register(joinpath(packages_dir, "Images"),
registry = "file://$(upstream2_dir)",
push = true, branch = "images", gitconfig = TEST_GITCONFIG)
@test readchomp(`$(downstream_git) log`) == readchomp(`$(upstream_git) log`)
# Can't use standard log format here since the time stamps will be different.
@test readchomp(`$(upstream_git) log --format=%T:%s images`) == readchomp(`$(upstream2_git) log --format=%T:%s images`)
@test length(readlines(`$(upstream2_git) log --format=%T:%s images`)) == 4
end
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants