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

error: couldn't fetch advisory database: git operation failed: reference 'refs/heads/master' not found; class=Reference (4); code=NotFound (-3) #32

Closed
robinst opened this issue Jul 23, 2018 · 14 comments

Comments

@robinst
Copy link

robinst commented Jul 23, 2018

I just installed cargo audit:

$ cargo audit --version
cargo-audit 0.3.2

But running it fails with "git operation failed":

$ cargo audit
    Fetching advisory database from `https://github.com/RustSec/advisory-db.git`
error: couldn't fetch advisory database: git operation failed: reference 'refs/heads/master' not found; class=Reference (4); code=NotFound (-3)

I tried cloning directly via git clone https://github.com/RustSec/advisory-db.git and that works, so not sure what the problem is.

@tarcieri
Copy link
Member

Can you reproduce this error? You can try cargo audit -D /tmp/tmp-advisory-db to force it to clone in a different location.

@robinst
Copy link
Author

robinst commented Jul 24, 2018

Yeah, happened every time. I ran cargo audit -D /tmp/tmp-advisory-db and that worked.

So I looked at ~/.cargo/advisory-db/ (didn't know about that before, maybe you can include it in the error message to help people). It looked like this:

$ find ~/.cargo/advisory-db/
/Users/rstocker/.cargo/advisory-db/
/Users/rstocker/.cargo/advisory-db//.git
/Users/rstocker/.cargo/advisory-db//.git/config
/Users/rstocker/.cargo/advisory-db//.git/objects
/Users/rstocker/.cargo/advisory-db//.git/objects/pack
/Users/rstocker/.cargo/advisory-db//.git/objects/pack/pack-b587a2eab8a13d1aae0c6a2c25d18755f1f16d85.pack
/Users/rstocker/.cargo/advisory-db//.git/objects/pack/pack-be51098f0483104a6d375f8550166df5911ac710.pack
/Users/rstocker/.cargo/advisory-db//.git/objects/pack/pack-b587a2eab8a13d1aae0c6a2c25d18755f1f16d85.idx
/Users/rstocker/.cargo/advisory-db//.git/objects/pack/pack-be51098f0483104a6d375f8550166df5911ac710.idx
/Users/rstocker/.cargo/advisory-db//.git/objects/info
/Users/rstocker/.cargo/advisory-db//.git/HEAD
/Users/rstocker/.cargo/advisory-db//.git/info
/Users/rstocker/.cargo/advisory-db//.git/info/exclude
/Users/rstocker/.cargo/advisory-db//.git/logs
/Users/rstocker/.cargo/advisory-db//.git/logs/refs
/Users/rstocker/.cargo/advisory-db//.git/logs/refs/remotes
/Users/rstocker/.cargo/advisory-db//.git/logs/refs/remotes/origin
/Users/rstocker/.cargo/advisory-db//.git/logs/refs/remotes/origin/master
/Users/rstocker/.cargo/advisory-db//.git/description
/Users/rstocker/.cargo/advisory-db//.git/hooks
/Users/rstocker/.cargo/advisory-db//.git/hooks/README.sample
/Users/rstocker/.cargo/advisory-db//.git/refs
/Users/rstocker/.cargo/advisory-db//.git/refs/heads
/Users/rstocker/.cargo/advisory-db//.git/refs/tags
/Users/rstocker/.cargo/advisory-db//.git/refs/remotes
/Users/rstocker/.cargo/advisory-db//.git/refs/remotes/origin
/Users/rstocker/.cargo/advisory-db//.git/refs/remotes/origin/master
/Users/rstocker/.cargo/advisory-db//.git/FETCH_HEAD

So then I did a rm -rf ~/.cargo/advisory-db/ just to try.

Now cargo audit works. So not sure what was wrong before, maybe the file list gives you a clue? Sorry, I should have moved the directory, not deleted it :).

@tarcieri
Copy link
Member

Sounds like the repository got into a bad state somehow. Looking at the similar Cargo code for managing the repositories it does quite a bit to clean up repositories in bad states, so it seems there is some work to do in that regard.

Glad recloning fixed your problems otherwise though. I'll try to add some error handling and cleanup logic to the repository fetcher and hopefully that will address the issue in the future.

One other question though: did this happen the first time you ran cargo audit, or did it work OK the first time and fail on a follow-up run?

@robinst
Copy link
Author

robinst commented Aug 8, 2018

One other question though: did this happen the first time you ran cargo audit, or did it work OK the first time and fail on a follow-up run?

I think I had the problem the first time I ran it.

@paul-tcell
Copy link

I notice this happens if $HOME/.cargo/advisory-db/ exists, but is empty. removing the directory entirely fixes it.

@tarcieri
Copy link
Member

@paul-tcell interesting! I'll try making a test case for that and see if I can reproduce it

@colindean
Copy link
Contributor

@tarcieri What work needs to be done? I might be able to take a look.

@tarcieri
Copy link
Member

@colindean a test needs to be added for these cases which captures this bug and the one in #45 (which both seem like two symptoms of the same root cause). After that, I feel like a std::fs::create_dir_all should resolve the issue.

@tarcieri
Copy link
Member

tarcieri commented Oct 14, 2018

This should be fixed by https://github.com/RustSec/rustsec-crate/pull/47, which was released as rustsec v0.9.2

@robinst
Copy link
Author

robinst commented Oct 15, 2018

Thank you!

@SyamiliV
Copy link

SyamiliV commented Feb 10, 2021

How do i install v0.9.2 alone? By default i can get only v0.13.1 version. Can you please help. I am having same problem

@SyamiliV
Copy link

cargo audit -D /tmp/tmp-advisory-db command not working for me

@garyanaplan
Copy link

I just hit this issue this morning:

cargo audit --version      
cargo-audit 0.14.0

I poked a few things with little luck. Then

rm -rf ~/.cargo/advisory-db kicked it into life.

tarcieri added a commit that referenced this issue May 7, 2021
README.md: Badge fixups, add gitter badge
tarcieri added a commit that referenced this issue May 7, 2021
Extracted from the `serde_derive`-generated `Serialize` impl.

We use this rather than the upstream one to allow for format detection.
tarcieri added a commit that referenced this issue May 7, 2021
(Re-)Add Serialize impl for Lockfile (fixes #32)
tarcieri added a commit that referenced this issue May 7, 2021
tarcieri pushed a commit that referenced this issue May 7, 2021
Add aarch64-apple-darwin to Platform list
@Kixunil

This comment was marked as off-topic.

@rustsec rustsec locked as too heated and limited conversation to collaborators Dec 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants