Git repository dependancy howto

Hello, bit of a n00b question I'm afraid, but I'm hitting a blocker trying to import some code that's on github. I've created two sample github projects to show case the error, please help me understand what I'm doing wrong... - has a sample function i want to use somewhere else - the program that should be importing the code in the other repo.

If I clone & cd into that repo, then type cargo build, I get the following error, which I don't understand since I can git clone the repository just fine... any thoughts?


➜  rustsampleuselib git:(main) cargo build
    Updating git repository ``
error: failed to get `rustsamplelib` as a dependency of package `rustsampleuselib v0.1.0 (/Users/jhiver/rustsampleuselib)`

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

Caused by:
  Unable to update (max 2 urls new user restriction, sorry...)

Caused by:
  failed to fetch into: /Users/jhiver/.cargo/git/db/rustsamplelib-5fcbef52960c3a46

Caused by:
  process didn't exit successfully: `git fetch --force --update-head-ok '' 'refs/heads/master:refs/remotes/origin/master'` (exit code: 128)
  --- stderr
  fatal: couldn't find remote ref refs/heads/master

You have branch="master" in Cargo.toml, but the branch is called main -- GitHub recently changed the default name of the main branch for new repositories.

1 Like

Oh boy sorry I didn't realize that. It was confusing because even when I didn't specify any branch it was looking for "master" as well and I specifically added it afterwards... lol...


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.