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

cargo build fails with git dependency in rust 1.44 #8352

Closed
Roguelazer opened this issue Jun 11, 2020 · 6 comments · Fixed by #8778
Closed

cargo build fails with git dependency in rust 1.44 #8352

Roguelazer opened this issue Jun 11, 2020 · 6 comments · Fixed by #8778
Labels
A-git Area: anything dealing with git C-bug Category: bug S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix

Comments

@Roguelazer
Copy link

Problem
Since Rust 1.44, cloning git dependencies fails the first time with an error like the following:

$ cargo build
    Updating git repository `ssh://git@internal-server/path/to/git-repo.git`
error: failed to get `internal-lib-name` as a dependency of package `internal_project v0.1.0 (/Users/jbrown/work/easypost/internal-project)`

Caused by:
  failed to load source for dependency `internal-lib-name`

Caused by:
  Unable to update ssh://git@internal-server/path/to/git-repo.git?tag=v0.1.0#f582cac3

Caused by:
  failed to clone into: /Users/jbrown/.cargo/git/db/internal-lib-name-835eff812df18c1c

Caused by:
  failed to authenticate when downloading repository
attempted ssh-agent authentication, but none of the usernames `git` succeeded

Caused by:
  failed to map '1'; class=Config (7)

Rerunning cargo build a second time always succeeds.

This worked fine in 1.43.

Steps

  1. Attempt to build a repo with a git dependency

Possible Solution(s)
Working on trying to make a minimal reproducer; figured I'd file this first.

Notes

Output of cargo version: cargo 1.44.0 (05d080faa 2020-05-06) (repros on macOS and Linux)

@Roguelazer Roguelazer added the C-bug Category: bug label Jun 11, 2020
@Roguelazer
Copy link
Author

Here's a minimal reproducer using one of the open-source libraries I maintain:

$ cargo new --bin issue-8352-test
     Created binary (application) `issue-8352-test` package
$ cd issue-8352-test
$ cat >Cargo.toml <<EOF
[package]
name = "i8352test"
version = "0.1.0"
authors = ["James Brown <[email protected]>"]

[dependencies]
mysql_binlog = { git = "ssh://[email protected]/EasyPost/rust-mysql-binlog", tag = "0.3.0", version = "0.3.0"}
EOF
$ cargo build
    Updating git repository `ssh://[email protected]/EasyPost/rust-mysql-binlog`
error: failed to get `mysql_binlog` as a dependency of package `i8352test v0.1.0 (/Users/jbrown/tmp/2020-06-11/issue-8352-test)`

Caused by:
  failed to load source for dependency `mysql_binlog`

Caused by:
  Unable to update ssh://[email protected]/EasyPost/rust-mysql-binlog?tag=0.3.0

Caused by:
  failed to fetch into /Users/jbrown/.cargo/git/db/rust-mysql-binlog-e9f9b299f3d76a53

Caused by:
  failed to authenticate when downloading repository
attempted ssh-agent authentication, but none of the usernames `git` succeeded

Caused by:
  failed to map '1'; class=Config (7)

@ehuss
Copy link
Contributor

ehuss commented Jun 11, 2020

failed to map indicates the git library failed to parse your .gitconfig. Can you narrow down which part of your .gitconfig is causing the error and post it here?

Also, FYI, your reproduction has a small mistake (the tag needs v as in tag = "v0.3.0").

@ehuss ehuss added A-networking Area: networking issues, curl, etc. A-git Area: anything dealing with git and removed A-networking Area: networking issues, curl, etc. labels Jun 11, 2020
@Roguelazer
Copy link
Author

It appears to be

[core]
    logAllRefUpdates = 1

which causes the issue

Perhaps your gitconfig parser does not handle 1 as an alias for true?

@ehuss
Copy link
Contributor

ehuss commented Jun 12, 2020

Yea, looks like an issue in the libgit2 library. I have filed a report at libgit2/libgit2#5555. A workaround is to use true.

I'm not yet sure why running twice works. For some reason, the second run thinks the repo is up-to-date. Perhaps the error happens late enough that the repo is partially updated. It will take some more investigation to figure that out.

@ehuss ehuss added the S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix label Jun 24, 2020
@ehuss ehuss mentioned this issue Oct 14, 2020
@bors bors closed this as completed in 60194f2 Oct 14, 2020
ehuss pushed a commit to ehuss/cargo that referenced this issue Oct 14, 2020
Update git2.

Closes rust-lang#8517
Closes rust-lang#8588
Closes rust-lang#8352
Closes rust-lang#4777
Closes rust-lang#8746

I only added a test for one of these. I can add for the others if you want.
@njerschow
Copy link

git clean -f fixed this for me

@JuiceDrinker
Copy link

If you ran into this and can clone using git cli adding --config net.git-fetch-with-cli=true to the end of your cargo command will fix it for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-git Area: anything dealing with git C-bug Category: bug S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants