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

Unable to add private registry #2779

Open
fcdimitr opened this issue Oct 17, 2021 · 7 comments
Open

Unable to add private registry #2779

fcdimitr opened this issue Oct 17, 2021 · 7 comments

Comments

@fcdimitr
Copy link

We are unable to add a private GitHub registry, specifically,

registry add git@github.com:user/PrivateRegistry.git

fails with the following trace.

 Cloning registry from “git@github.com:user/PrivateRegistry.git”
ERROR: BoundsError: attempt to access 1024-element Vector{UInt8} at index [0x0000000000000001:0x00007ff934e138e0]
Stacktrace:
 [1] throw_boundserror(A::Vector{UInt8}, I::Tuple{UnitRange{UInt64}})
  @ Base ./abstractarray.jl:651
 [2] checkbounds
  @ ./abstractarray.jl:616 [inlined]
 [3] _getindex
  @ ./multidimensional.jl:831 [inlined]
 [4] getindex
  @ ./abstractarray.jl:1170 [inlined]
 [5] ssh_knownhost_check
  @ /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/LibGit2/src/callbacks.jl:436 [inlined]
 [6] certificate_callback(cert_p::Ptr{LibGit2.CertHostKey}, valid::Int32, host_p::Ptr{Int8}, data_p::Ptr{Nothing})
  @ LibGit2 /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/LibGit2/src/callbacks.jl:401
 [7] macro expansion
  @ /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/LibGit2/src/error.jl:108 [inlined]
 [8] clone(repo_url::SubString{String}, repo_path::String, clone_opts::LibGit2.CloneOptions)
  @ LibGit2 /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/LibGit2/src/repository.jl:459
 [9] clone(repo_url::SubString{String}, repo_path::String; branch::String, isbare::Bool, remote_cb::Ptr{Nothing}, credentials::LibGit2.CachedCredentials, callbacks::Dict{Symbol, Tuple{Ptr{Nothing}, Any}})
  @ LibGit2 /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/LibGit2/src/LibGit2.jl:583
 [10] clone(ctx::Pkg.Types.Context, url::String, source_path::String; header::String, credentials::Nothing, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
  @ Pkg.GitTools /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/GitTools.jl:109
 [11] (::Pkg.Types.var”#82#85"{Pkg.Types.Context, String, Pkg.Types.RegistrySpec})(tmp::String)
  @ Pkg.Types /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/Types.jl:1048
 [12] mktempdir(fn::Pkg.Types.var”#82#85"{Pkg.Types.Context, String, Pkg.Types.RegistrySpec}, parent::String; prefix::String)
  @ Base.Filesystem ./file.jl:729
 [13] mktempdir (repeats 2 times)
  @ ./file.jl:727 [inlined]
 [14] clone_or_cp_registries(ctx::Pkg.Types.Context, regs::Vector{Pkg.Types.RegistrySpec}, depot::String)
  @ Pkg.Types /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/Types.jl:1027
 [15] clone_or_cp_registries
  @ /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/Types.jl:1020 [inlined]
 [16] #add#6
  @ /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/Registry.jl:32 [inlined]
 [17] add
  @ /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/Registry.jl:28 [inlined]
 [18] #add#5
  @ /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/Registry.jl:26 [inlined]
 [19] add(regs::Vector{Pkg.Types.RegistrySpec})
  @ Pkg.Registry /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/Registry.jl:26
 [20] do_cmd!(command::Pkg.REPLMode.Command, repl::REPL.LineEditREPL)
  @ Pkg.REPLMode /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/REPLMode/REPLMode.jl:408
 [21] do_cmd(repl::REPL.LineEditREPL, input::String; do_rethrow::Bool)
  @ Pkg.REPLMode /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/REPLMode/REPLMode.jl:386
 [22] do_cmd
  @ /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/REPLMode/REPLMode.jl:377 [inlined]
 [23] (::Pkg.REPLMode.var”#24#27"{REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
  @ Pkg.REPLMode /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/REPLMode/REPLMode.jl:550
 [24] #invokelatest#2
  @ ./essentials.jl:708 [inlined]
 [25] invokelatest
  @ ./essentials.jl:706 [inlined]
 [26] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
  @ REPL.LineEdit /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2441
 [27] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
  @ REPL /private/tmp/julia-20210929-79571-nlx62p/julia-1.6.3/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1126
 [28] (::REPL.var”#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
  @ REPL ./task.jl:411

We have verified that the command

git clone git@github.com:user/PrivateRegistry.git

works on the command line.

I am also attaching the output of versioninfo()

Julia Version 1.6.3
Commit ae8452a9e0 (2021-09-23 17:34 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin20.6.0)
  CPU: Intel(R) Core(TM) i5-4288U CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, haswell)

The registry has worked on a different machine with the following setup

Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, haswell)

Any ideas?

Many thanks in advance!

@KristofferC
Copy link
Sponsor Member

KristofferC commented Oct 18, 2021

ERROR: BoundsError: attempt to access 1024-element Vector{UInt8} at index [0x0000000000000001:0x00007ff934e138e0]

Something is going wrong here, looking at

https://github.com/JuliaLang/julia/blob/7b76c7e50a4eda78a556d4677900c854fbbcfc8d/stdlib/LibGit2/src/callbacks.jl#L436

and

julia> 0x00007ff934e138e0 |> Int
140708310759648

It seems to think the certificate length is very long.

Looking at git blame, @StefanKarpinski has a lot of modifications to this code in JuliaLang/julia#39324 and JuliaLang/julia#38506 but I am not sure if the problematic code originated there.

If you are able to do some debugging, I would follow the code up from the stacktrace and try to figure out where this incorrect length gets set.

@kabeero
Copy link

kabeero commented Nov 13, 2021

same problem on macOS / homebrew Julia 1.6.3

fails with ssh, e.g: registry add git@gitlab... but registry add https://gitlab... works

@asparagii
Copy link

As a temporary workaround, you can set the environment variable JULIA_PKG_USE_CLI_GIT=true, as suggested here: #2937 (comment)

This way Pkg will use the alternative pathway to clone repositories, which should work correctly.

@StefanKarpinski
Copy link
Sponsor Member

Are you using an official build of Julia?

@DilumAluthge
Copy link
Member

Can you provide the exact steps that you followed when you installed Julia?

@kabeero
Copy link

kabeero commented Jan 14, 2022

julia 1.6.3, 1.7+ built from git or using homebrew show the same behavior described above with public / private key-pairs (generated with ssh-keygen, added to ssh-agent with ssh-add)

JULIA_PKG_USE_CLI_GIT=true does remedy this problem, I might recompile Pkg.jl with this permanently enabled


additionally it seems there is another ssh issue with CA-signed public certificates... again
JULIA_PKG_USE_CLI_GIT=true fixes this issue but seems like a workaround / hack

(@v1.7) pkg> registry add git@private.com:MyJuliaRegistry/Custom.git
     Cloning registry from "git@private.com:MyJuliaRegistry/Custom.git"
ERROR: type CertHostKey has no field data
Stacktrace:
  [1] getproperty
    @ ./Base.jl:42 [inlined]
  [2] ssh_knownhost_check(files::Vector{String}, host::String, cert::LibGit2.CertHostKey)
    @ LibGit2 /usr/local/Cellar/julia/1.7.1_2/share/julia/stdlib/v1.7/LibGit2/src/callbacks.jl:436
  [3] certificate_callback(cert_p::Ptr{LibGit2.CertHostKey}, valid::Int32, host_p::Ptr{Int8}, data_p::Ptr{Nothing})
    @ LibGit2 /usr/local/Cellar/julia/1.7.1_2/share/julia/stdlib/v1.7/LibGit2/src/callbacks.jl:401
  [4] macro expansion
    @ /usr/local/Cellar/julia/1.7.1_2/share/julia/stdlib/v1.7/LibGit2/src/error.jl:108 [inlined]
  [5] clone(repo_url::SubString{String}, repo_path::String, clone_opts::LibGit2.CloneOptions)
    @ LibGit2 /usr/local/Cellar/julia/1.7.1_2/share/julia/stdlib/v1.7/LibGit2/src/repository.jl:459
  [6] clone(repo_url::SubString{String}, repo_path::String; branch::String, isbare::Bool, remote_cb::Ptr{Nothing}, credentials::LibGit2.CachedCredentials, callbacks::Dict{Symbol, Tuple{Ptr{Nothing}, Any}})
    @ LibGit2 /usr/local/Cellar/julia/1.7.1_2/share/julia/stdlib/v1.7/LibGit2/src/LibGit2.jl:583
  [7] clone(io::Base.TTY, url::String, source_path::String; header::String, credentials::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
  ...

@KristofferC
Copy link
Sponsor Member

The CertHostKey does have a data field:

https://github.com/JuliaLang/julia/blob/3f024fd0ab9e68b37d29fee6f2a9ab19819102c5/stdlib/LibGit2/src/callbacks.jl#L370

So something is perhaps strange with your setup?

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

6 participants