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

Libgit2 ERROR: AssertionError: name == "helper" #45693

Closed
PetrKryslUCSD opened this issue Jun 15, 2022 · 15 comments · Fixed by #46597
Closed

Libgit2 ERROR: AssertionError: name == "helper" #45693

PetrKryslUCSD opened this issue Jun 15, 2022 · 15 comments · Fixed by #46597
Labels
bug Indicates an unexpected problem or unintended behavior libgit2 The libgit2 library or the LibGit2 stdlib module

Comments

@PetrKryslUCSD
Copy link

When cloning a package (upon adding a package from Github using a url), I have found this error:
](https://discourse.julialang.org/t/libgit2-error-assertionerror-name-helper/82783)

@PetrKryslUCSD
Copy link
Author

I am still getting this error (Julia 1.7.2 on Windows 10):


(SteelSphere) pkg> add https://github.com/PetrKryslUCSD/BEMScat.jl.git
     Cloning git-repo `https://github.com/PetrKryslUCSD/BEMScat.jl.git`
ERROR: AssertionError: name == "helper"
Stacktrace:
  [1] credential_helpers(cfg::LibGit2.GitConfig, cred::LibGit2.GitCredential)
    @ LibGit2 C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\LibGit2\src\gitcredential.jl:224
  [2] fill!(cfg::LibGit2.GitConfig, cred::LibGit2.GitCredential)
    @ LibGit2 C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\LibGit2\src\gitcredential.jl:148
  [3] GitCredential
    @ C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\LibGit2\src\gitcredential.jl:30 [inlined]
  [4] authenticate_userpass(libgit2credptr::Ptr{Ptr{Nothing}}, p::LibGit2.CredentialPayload)
    @ LibGit2 C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\LibGit2\src\callbacks.jl:193
  [5] credentials_callback(libgit2credptr::Ptr{Ptr{Nothing}}, url_ptr::Cstring, username_ptr::Cstring, allowed_types::UInt32, p::LibGit2.CredentialPayload)
    @ LibGit2 C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\LibGit2\src\callbacks.jl:328
  [6] credentials_callback(libgit2credptr::Ptr{Ptr{Nothing}}, url_ptr::Cstring, username_ptr::Cstring, allowed_types::UInt32, payloads::Dict{Symbol, Any})
    @ LibGit2 C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\LibGit2\src\callbacks.jl:351
  [7] macro expansion
    @ C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\LibGit2\src\error.jl:108 [inlined]
  [8] clone(repo_url::SubString{String}, repo_path::String, clone_opts::LibGit2.CloneOptions)
    @ LibGit2 C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\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 C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\LibGit2\src\LibGit2.jl:583
 [10] clone(io::Base.TTY, url::String, source_path::String; header::Nothing, credentials::Nothing, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:isbare,), Tuple{Bool}}})
    @ Pkg.GitTools C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\GitTools.jl:115
 [11] #ensure_clone#2
    @ C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\GitTools.jl:74 [inlined]
 [12] handle_repo_add!(ctx::Pkg.Types.Context, pkg::Pkg.Types.PackageSpec)
    @ Pkg.Types C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\Types.jl:676
 [13] handle_repos_add!(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.Types C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\Types.jl:743
 [14] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
    @ Pkg.API C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\API.jl:248
 [15] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\API.jl:149
 [16] add(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\API.jl:144
 [17] do_cmd!(command::Pkg.REPLMode.Command, repl::REPL.LineEditREPL)
    @ Pkg.REPLMode C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\REPLMode\REPLMode.jl:407
 [18] do_cmd(repl::REPL.LineEditREPL, input::String; do_rethrow::Bool)
    @ Pkg.REPLMode C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\REPLMode\REPLMode.jl:385
 [19] do_cmd
    @ C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\REPLMode\REPLMode.jl:376 [inlined]
 [20] (::Pkg.REPLMode.var"#24#27"{REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ Pkg.REPLMode C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\REPLMode\REPLMode.jl:549
 [21] #invokelatest#2
    @ .\essentials.jl:716 [inlined]
 [22] invokelatest
    @ .\essentials.jl:714 [inlined]
 [23] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\REPL\src\LineEdit.jl:2493
 [24] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\pkonl\VSCode_Julia_portable\assets\julia-1.7.2\share\julia\stdlib\v1.7\REPL\src\REPL.jl:1232
 [25] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL .\task.jl:423

(SteelSphere) pkg> 

@PetrKryslUCSD
Copy link
Author

It is happening with 1.8 too.

@fredrikekre
Copy link
Member

I am guessing that you have a messed up or unexpected git config file on your system. LibGit2 is looking for the credential.helper entry, but finds something else:

for entry in GitConfigIter(cfg, r"credential.*\.helper")
section, url, name, value = split_cfg_entry(entry)
@assert name == "helper"

@PetrKryslUCSD
Copy link
Author

PetrKryslUCSD commented Jun 24, 2022

This is what I have in .gitconfig:

[credential "helperselector"]
	selected = manager-core

When I delete it, it is re-introduced when I click "Select" in the following dialogue (which comes up by default, courtesy of Git)
image

@PetrKryslUCSD
Copy link
Author

@fredrikekre It seems to me the code is making incorrect assumptions of what that "credential helper" entry should be.

@PetrKryslUCSD
Copy link
Author

A manual override of this form removes the error.


[credential]
	helper = 

Nevertheless, this should probably be fixed up. At least on Windows, this is likely to happen to other users.

@PetrKryslUCSD
Copy link
Author

@fredrikekre The issue is caused by the newest Git: Git for Windows v2.23.0 introduced a meta credential helper.
desktop/desktop#9597 (comment)

@PetrKryslUCSD
Copy link
Author

@fredrikekre Ping.

@PetrKryslUCSD
Copy link
Author

Meaning: has there been any progress on fixing this issue?

@PetrKryslUCSD PetrKryslUCSD added bug Indicates an unexpected problem or unintended behavior libgit2 The libgit2 library or the LibGit2 stdlib module labels Aug 17, 2022
@PetrKryslUCSD
Copy link
Author

Julia 1.8 release is still broken.

@JeffreySarnoff
Copy link
Contributor

as is 1.9, it seems

Pkg.add(url=s"https://github.com/...")
ERROR: AssertionError: name == "helper"
Stacktrace:
  [1] credential_helpers(cfg::LibGit2.GitConfig, cred::LibGit2.GitCredential)
    @ LibGit2 C:\Users\MrJSa\AppData\Local\Programs\Julia-1.9\share\julia\stdlib\v1.9\LibGit2\src\gitcredential.jl:224

@JeffreySarnoff
Copy link
Contributor

I fixed it by editing .gitconfig and leaving the first [credential], deleting the second.

@barucden
Copy link
Contributor

barucden commented Sep 1, 2022

I looked into this issue.

Although it does not involve LibGit2, I think this (linux) example shows the problem:

cd `mktemp -d`
git init
git config credential.helper 'cache --timeout=86400'
git config credential.someurl.helper 'cache --timeout=86400'
echo '[credential "helperselector"]
        selected = manager-core' >> .git/config

The config file contains (cat .git/config):

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[credential]
        helper = cache --timeout=86400
[credential "someurl"]
        helper = cache --timeout=86400
[credential "helperselector"]
        selected = manager-core

Then the following query

git config --get-regexp credential.*\.helper

prints

credential.helper cache --timeout=86400
credential.someurl.helper cache --timeout=86400
credential.helperselector.selected manager-core

Adjusting the regex

git config --get-regexp credential.*\.helper$

helps:

credential.helper cache --timeout=86400
credential.someurl.helper cache --timeout=86400

@PetrKryslUCSD
Copy link
Author

PetrKryslUCSD commented Sep 1, 2022

If you mean that the fix might be as easy as

for entry in GitConfigIter(cfg, r"credential.*\.helper$")

then I agree with you.

for entry in GitConfigIter(cfg, r"credential.*\.helper")

@barucden
Copy link
Contributor

barucden commented Sep 2, 2022

I do think that it should help with your problem. But I'm worried about something else breaking.

I'll prepare a PR and let's see what people (and the testset) think.

barucden added a commit to barucden/julia that referenced this issue Sep 2, 2022
The previous regex for credential helpers included even the following
credential:

```
[credential "helperselector"]
    selected = manager-core
```

which gets introduced by Git for Windows and fails our assumption about
what a credential helper is.

The commit also removes a test that mirrors what `credential_helpers`
does (otherwise, we would have to maintain the same regex at two places,
the definition of `credential_helpers` and the test case).

Fixes JuliaLang#45693
barucden added a commit to barucden/julia that referenced this issue Sep 6, 2022
The previous regex for credential helpers included even the following
credential:

```
[credential "helperselector"]
    selected = manager-core
```

which gets introduced by Git for Windows and fails our assumption about
what a credential helper is.

The commit also removes a test that mirrors what `credential_helpers`
does (otherwise, we would have to maintain the same regex at two places,
the definition of `credential_helpers` and the test case).

Fixes JuliaLang#45693
KristofferC pushed a commit that referenced this issue Sep 16, 2022
The previous regex for credential helpers included even the following
credential:

```
[credential "helperselector"]
    selected = manager-core
```

which gets introduced by Git for Windows and fails our assumption about
what a credential helper is.

The commit also removes a test that mirrors what `credential_helpers`
does (otherwise, we would have to maintain the same regex at two places,
the definition of `credential_helpers` and the test case).

Fixes #45693

(cherry picked from commit ea74208)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior libgit2 The libgit2 library or the LibGit2 stdlib module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants