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

Improve error message when unable to initialize git index repo #9869

Merged
merged 1 commit into from
Sep 3, 2021

Conversation

nipunn1313
Copy link
Contributor

@nipunn1313 nipunn1313 commented Sep 3, 2021

With this - it'll be more obvious which git repo
couldn't be initialized.

Looks like this

➜  cargo RUST_BACKTRACE=1 target/debug/cargo build
error: failed to get `anyhow` as a dependency of package `cargo v0.57.0 (/Users/nipunn/src/cargo)`

Caused by:
  failed to initialize index git repository (in "/Users/nipunn/.cargo/registry/index/github.com-1ecc6299db9ec823")

Caused by:
  failed to parse config file: invalid configuration key (in /Users/nipunn/.config/git/config:1); class=Config (7)

Does the best we can with #9854 - since I don't think it can actually be fixed.
Fixes #9854

With this - it'll be more obvious which git repo
couldn't be initialized.
@rust-highfive
Copy link

r? @alexcrichton

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 3, 2021
@alexcrichton
Copy link
Member

@bors: r+

Thanks! I'm a bit uncertain on whether this closes the issue, but I'm ok doing that for now. I think that Cargo relies on enough git things that it wouldn't be great to ignore the errors here and I'm hoping that it's something that's either easily fixable in the gitconfig itself or is something that can be fixed in libgit2.

@bors
Copy link
Contributor

bors commented Sep 3, 2021

📌 Commit 168fac4 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 3, 2021
@bors
Copy link
Contributor

bors commented Sep 3, 2021

⌛ Testing commit 168fac4 with merge d405d73...

@nipunn1313
Copy link
Contributor Author

The specific gitconfig issue (incorrectly assuming it's malformed) #9853 should be fixed - via a fix to libgit2

However, I don't think #9854 can be fixed - it's asking for cargo to work despite a malformed gitconfig. AFAICT cargo can't initialize the registry in this kind of case and has to fail.

This is my understanding - what do you think?

@alexcrichton
Copy link
Member

I think it sort of depends on the error. While giving a better error is certainly better than the status quo I also don't think that this is something that users should be running into regularly. For example I wouldn't want to hide bugs in libgit2 but if users frequently hit the same bug in libgit2 then that helps us prioritize fixing it and/or reporting it upstream.

Basically this shouldn't happen, but there's no way really to predict why it will happen to preemptively cover it up. There may be some situations though where it's reasonable to ignore the global config, but I don't know them off the top of my head, so just having a better error for now I think is fine.

@bors
Copy link
Contributor

bors commented Sep 3, 2021

☀️ Test successful - checks-actions
Approved by: alexcrichton
Pushing d405d73 to master...

@bors bors merged commit d405d73 into rust-lang:master Sep 3, 2021
Manishearth added a commit to Manishearth/rust that referenced this pull request Sep 12, 2021
Update cargo

6 commits in 18751dd3f238d94d384a7fe967abfac06cbfe0b9..e515c3277bf0681bfc79a9e763861bfe26bb05db
2021-09-01 14:26:00 +0000 to 2021-09-08 14:32:15 +0000
- Remove log output that may leak tokens (rust-lang/cargo#9873)
- rev = "refs/pull/𑑛/head" (rust-lang/cargo#9859)
- Update suggestion message on bad project name error (rust-lang/cargo#9877)
- clarify what goes into "*-sys" crates (rust-lang/cargo#9871)
- Improve error message when unable to initialize git index repo (rust-lang/cargo#9869)
- Use serde_json to generate cargo_vcs_info.json (rust-lang/cargo#9865)
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 13, 2021
Update cargo

6 commits in 18751dd3f238d94d384a7fe967abfac06cbfe0b9..e515c3277bf0681bfc79a9e763861bfe26bb05db
2021-09-01 14:26:00 +0000 to 2021-09-08 14:32:15 +0000
- Remove log output that may leak tokens (rust-lang/cargo#9873)
- rev = "refs/pull/𑑛/head" (rust-lang/cargo#9859)
- Update suggestion message on bad project name error (rust-lang/cargo#9877)
- clarify what goes into "*-sys" crates (rust-lang/cargo#9871)
- Improve error message when unable to initialize git index repo (rust-lang/cargo#9869)
- Use serde_json to generate cargo_vcs_info.json (rust-lang/cargo#9865)
@nipunn1313 nipunn1313 deleted the errmsg branch September 26, 2021 17:25
@ehuss ehuss added this to the 1.57.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cargo becomes unusable if gitconfig is malformed
5 participants