Skip to content

gix fails to read credential store in ~/.git-credentialsΒ #1103

Closed
@jalil-salame

Description

@jalil-salame

Current behavior 😯

gix fetch fails on a repository using a Token for authentication. The token is stored in ~/.git-credentials:

~/.git-credentials
https://git:[[TOKEN]]@sharelatex.tum.de

The config is not minimal

gix config
# From 'C:/Program Files/Git/etc/gitconfig' (GitInstallation)
[diff "astextplain"]
        textconv = astextplain

[filter "lfs"]
        clean = git-lfs clean -- %f
        smudge = git-lfs smudge -- %f
        process = git-lfs filter-process
        required = true

[http]
        sslBackend = openssl
        sslCAInfo = C:/Program Files/Git/mingw64/etc/ssl/certs/ca-bundle.crt

[core]
        autocrlf = true
        fscache = true
        symlinks = false

[pull]
        rebase = false

[credential]
        helper = manager
[credential "https://dev.azure.com"]
        useHttpPath = true

[init]
        defaultBranch = master

# From 'D:\Users\[[REDACTED]]\.gitconfig' (User)
[http]
        proxy = [[REDACTED]]
        sslVerify = false

[https]
        proxy = [[REDACTED]]

[delta]
        navigate = true
        light = false
        line-numbers = true
        zero-style = dim syntax

[core]
        pager = delta
        autocrlf = false

[interactive]
        diffFilter = delta --color-only

[merge]
        conflictstyle = diff3

[diff]
        colorMoved = default

[credential]
        helper = store
[credential "https://sharelatex.tum.de"]
        provider = generic

# From '.\.git\config' (Local)
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true

[remote "origin"]
        url = https://[email protected]/git/[[REDACTED]]
        fetch = +refs/heads/*:refs/remotes/origin/*

[branch "master"]
        remote = origin
        merge = refs/heads/master

# From 'memory' (EnvOverride)
[gitoxide "https"]
        proxy = [[REDACTED]] # from HTTPS_PROXY
        proxy = [[REDACTED]] # from https_proxy
[gitoxide "http"]
        noProxy = [[REDACTED]] # from NO_PROXY
        noProxy = [[REDACTED]] # from no_proxy
        proxy = [[REDACTED]] # from http_proxy

I am behind a corporate proxy using a windows computer. So I have to be kinda careful about what logs I post :c.

I am using gitoxide-max-pure-v0.31.1-x86_64-pc-windows-msvc from the GitHub releases.

gix --trace fetch
$ gix --trace fetch
 12:04:48 tracing TRACE    πŸ“ [trace]: checkout waiting for idle connection: ("https", sharelatex.tum.de)
 12:04:48 tracing TRACE    πŸ“ [trace]: Http::connect; scheme=Some("http"), host=Some("[[REDACTED]]"), port=Some(Port(8080))
 12:04:48 tracing TRACE    πŸ“ [trace]: handle passed back
 12:04:48 tracing DEBUG    πŸ› [debug]: querying: [[REDACTED]] A
 12:04:48 tracing DEBUG    πŸ› [debug]: sending request: [Query { name: Name("[[REDACTED]]"), query_type: A, query_class: IN }]
 12:04:48 tracing DEBUG    πŸ› [debug]: reconnecting: NameServerConfig { socket_addr: [[REDACTED]], protocol: Udp, tls_dns_name: None, trust_nx_responses: false, bind_addr: None }
 12:04:48 tracing DEBUG    πŸ› [debug]: enqueueing message:QUERY:[Query { name: Name("[[REDACTED]]"), query_type: A, query_class: IN }]
 12:04:48 tracing DEBUG    πŸ› [debug]: reconnecting: NameServerConfig { socket_addr: [[REDACTED]], protocol: Udp, tls_dns_name: None, trust_nx_responses: false, bind_addr: None }
 12:04:48 tracing DEBUG    πŸ› [debug]: enqueueing message:QUERY:[Query { name: Name("[[REDACTED]]"), query_type: A, query_class: IN }]
 12:04:48 tracing DEBUG    πŸ› [debug]: final message: ; header 12763:QUERY:RD:NoError:QUERY:0/0/0
 12:04:48 tracing ; query
 12:04:48 tracing ;; [[REDACTED]] IN A
 12:04:48 tracing
 12:04:48 tracing DEBUG    πŸ› [debug]: final message: ; header 9177:QUERY:RD:NoError:QUERY:0/0/0
 12:04:48 tracing ; query
 12:04:48 tracing ;; [[REDACTED]] IN A
 12:04:48 tracing
 12:04:48 tracing DEBUG    πŸ› [debug]: created socket successfully
 12:04:48 tracing DEBUG    πŸ› [debug]: created socket successfully
 12:04:48 tracing TRACE    πŸ“ [trace]: reading CNAME
 12:04:48 tracing TRACE    πŸ“ [trace]: reading A
 12:04:48 tracing TRACE    πŸ“ [trace]: reading NS
 12:04:48 tracing TRACE    πŸ“ [trace]: reading NS
 12:04:48 tracing TRACE    πŸ“ [trace]: reading A
 12:04:48 tracing TRACE    πŸ“ [trace]: reading A
 12:04:48 tracing DEBUG    πŸ› [debug]: received message id: 12763
 12:04:48 tracing DEBUG    πŸ› [debug]: Response:; header 12763:RESPONSE:RD,AA,RA:NoError:QUERY:2/2/2
 12:04:48 tracing ; query
 12:04:48 tracing ;; [[REDACTED]] IN A
 12:04:48 tracing ; answers 2
 12:04:48 tracing [[REDACTED]] 600 IN CNAME [[REDACTED]]
 12:04:48 tracing [[REDACTED]] 12 IN A [[REDACTED]]
 12:04:48 tracing ; nameservers 2
 12:04:48 tracing [[REDACTED]] 600 IN NS [[REDACTED]]
 12:04:48 tracing [[REDACTED]] 600 IN NS [[REDACTED]]
 12:04:48 tracing ; additionals 2
 12:04:48 tracing [[REDACTED]] 600 IN A [[REDACTED]]
 12:04:48 tracing [[REDACTED]] 600 IN A [[REDACTED]]
 12:04:48 tracing
 12:04:48 tracing DEBUG    πŸ› [debug]: Response:; header 12763:RESPONSE:RD,AA,RA:NoError:QUERY:2/2/2
 12:04:48 tracing ; query
 12:04:48 tracing ;; [[REDACTED]] IN A
 12:04:48 tracing ; answers 2
 12:04:48 tracing [[REDACTED]] 600 IN CNAME [[REDACTED]]
 12:04:48 tracing [[REDACTED]] 12 IN A [[REDACTED]]
 12:04:48 tracing ; nameservers 2
 12:04:48 tracing [[REDACTED]] 600 IN NS [[REDACTED]]
 12:04:48 tracing [[REDACTED]] 600 IN NS [[REDACTED]]
 12:04:48 tracing ; additionals 2
 12:04:48 tracing [[REDACTED]] 600 IN A [[REDACTED]]
 12:04:48 tracing [[REDACTED]] 600 IN A [[REDACTED]]
 12:04:48 tracing
 12:04:48 tracing DEBUG    πŸ› [debug]: connecting to [[REDACTED]]
 12:04:48 tracing DEBUG    πŸ› [debug]: connected to [[REDACTED]]
 12:04:49 tracing TRACE    πŸ“ [trace]: client handshake Http1
 12:04:49 tracing TRACE    πŸ“ [trace]: handshake complete, spawning background dispatcher task
 12:04:49 tracing TRACE    πŸ“ [trace]: flushed({role=client}): State { reading: Init, writing: Init, keep_alive: Busy }
 12:04:49 tracing TRACE    πŸ“ [trace]: checkout dropped for ("https", sharelatex.tum.de)
 12:04:49 tracing TRACE    encode_headers [ 26.1Β΅s | 100.00% ]
 12:04:49 tracing TRACE    ┕━ πŸ“ [trace]: Client::encode method=GET, body=None
 12:04:49 tracing DEBUG    πŸ› [debug]: flushed 204 bytes
 12:04:49 tracing TRACE    πŸ“ [trace]: flushed({role=client}): State { reading: Init, writing: KeepAlive, keep_alive: Busy }
 12:04:49 tracing TRACE    πŸ“ [trace]: Conn::read_head
 12:04:49 tracing TRACE    πŸ“ [trace]: received 332 bytes
 12:04:49 tracing TRACE    parse_headers [ 42.0Β΅s | 100.00% ]
 12:04:49 tracing TRACE    ┝━ πŸ“ [trace]: Response.parse | bytes: 332
 12:04:49 tracing TRACE    ┕━ πŸ“ [trace]: Response.parse Complete(171)
 12:04:49 tracing DEBUG    πŸ› [debug]: parsed 5 headers
 12:04:49 tracing DEBUG    πŸ› [debug]: incoming body is content-length (161 bytes)
 12:04:49 tracing TRACE    πŸ“ [trace]: decode; state=Length(161)
 12:04:49 tracing DEBUG    πŸ› [debug]: incoming body completed
 12:04:49 tracing TRACE    πŸ“ [trace]: maybe_notify; read_from_io blocked
 12:04:49 tracing TRACE    πŸ“ [trace]: flushed({role=client}): State { reading: Init, writing: Init, keep_alive: Idle }
 12:04:49 tracing TRACE    πŸ“ [trace]: flushed({role=client}): State { reading: Init, writing: Init, keep_alive: Idle }
 12:04:49 tracing TRACE    πŸ“ [trace]: put; add idle connection for ("https", sharelatex.tum.de)
 12:04:49 tracing DEBUG    πŸ› [debug]: pooling idle connection for ("https", sharelatex.tum.de)
 12:04:49 tracing TRACE    πŸ“ [trace]: flushed({role=client}): State { reading: Init, writing: Init, keep_alive: Idle }
 12:04:49 tracing INFO     run [ 289ms | 53.69% / 100.00% ]
 12:04:49 tracing INFO     ┕━ ThreadSafeRepository::discover() [ 134ms | 1.16% / 46.31% ]
 12:04:49 tracing INFO        ┕━ open_from_paths() [ 131ms | 21.68% / 45.15% ]
 12:04:49 tracing INFO           ┝━ gix_path::git::install_config_path() [ 67.2ms | 23.22% ]
 12:04:49 tracing INFO           ┕━ gix_odb::Store::at() [ 714Β΅s | 0.25% ]
Error: Failed to obtain credentials

Caused by:
    0: An IO error occurred while communicating to the credentials helper
    1: program not found

Expected behavior πŸ€”

gix fetch should use the credentials in ~/.git-credentials and successfully establish the connection.

Git behavior

git fetch just works.

Steps to reproduce πŸ•Ή

I will try to reproduce it in the public Overleaf instance instead of my University's but this are the steps:

  1. Create an Overleaf project (on my uni's instance(?))
  2. Enable git integration
  3. Use the token to clone the project.
  4. Store the token using git credentials store (in ~/.git-credentials)
  5. Try to fetch with gix (no updates to the repo required) (maybe you need to be behind an http proxy(?))

As far as I can tell this only happens on windows(?), but I didn't use the git credentials store within linux. I will try that ASAP, but I'm filing the issue while I'm still behind the proxy.

Performed tests (Results in the comments)

  • Windows GIT_TRACE=1 git fetch
  • Test on Windows with main
  • Test on Windows with v0.30.0
  • Test on Windows without ~/.git-credentials
  • Test on Windows w/o proxy
  • Test on Windows with public Overleaf instance
  • Test on Windows with private GitHub Repo
  • Linux GIT_TRACE=1 git fetch
  • Test on Linux with main
  • Test on Linux with v0.31.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions