Skip to content

Commit

Permalink
Auto merge of #9869 - nipunn1313:errmsg, r=alexcrichton
Browse files Browse the repository at this point in the history
Improve error message when unable to initialize git index repo

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
  • Loading branch information
bors committed Sep 3, 2021
2 parents 8da3cf7 + 168fac4 commit d405d73
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cargo/sources/registry/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ impl<'cfg> RemoteRegistry<'cfg> {
// things that we don't want.
let mut opts = git2::RepositoryInitOptions::new();
opts.external_template(false);
Ok(git2::Repository::init_opts(&path, &opts)
.with_context(|| "failed to initialize index git repository")?)
Ok(git2::Repository::init_opts(&path, &opts).with_context(|| {
format!("failed to initialize index git repository (in {:?})", path)
})?)
}
}
})
Expand Down

0 comments on commit d405d73

Please sign in to comment.