sexta-feira, 21 de março de 2025

Solution to failed to acquire username/password from local configuration on rust git libs

Let's say you need to work on a Rust project that depends on other libraries hosted in a private Git repository. This project uses the repository's HTTPS URL. For example:



your-lib = { git = "ssh://git@github.com/your-company/your-lib.git"}

Then you try to start the project and encounter the following error:


$ cargo run

    Blocking waiting for file lock on package cache

    Updating crates.io index

    Updating git repository `https://github.com/your-company/your-lib.git`

error: failed to get `outbox-pattern-processor` as a dependency of package `anti-fraud-service v0.1.0 (/project/your-project)`

Caused by:

  failed to load source for dependency `your-lib`

Caused by:

  Unable to update https://github.com/your-company/your-lib.git?tag=v1.0.0#49efa247

Caused by:

  failed to fetch into: /home/tiago.motta/.cargo/git/db/your-lib-31d59910066df49a

Caused by:

  revision 49efa2476e2613cf809315b4b0abf16f079b5dcb not found

Caused by:

  failed to authenticate when downloading repository

  * attempted to find username/password via git's `credential.helper` support, but failed

  if the git CLI succeeds then `net.git-fetch-with-cli` may help here

  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:

  failed to acquire username/password from local configuration


The solution is simple. Just edit your global .gitconfig to replace HTTPS URLs with SSH by adding the following lines:


[url "ssh://git@github.com/"]

insteadOf = https://github.com/




Nenhum comentário:

Postar um comentário