The Rust package manager https://doc.rust-lang.org/cargo
  • Rust 96%
  • Roff 3.6%
  • JavaScript 0.2%
  • Shell 0.1%
Find a file
Weihang Lo bb2126cffa
fix(git)!: Default to net.git-fetch-with-cli if git is present (#17329)
*[View all
comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/cargo/pull/17329)*

### What does this PR try to resolve?

This changes the default for how we fetch to use the git CLI if present
for better conformity and performance without breaking people (yet) who
don't have it.

Part of #17227

### How to test and review this PR?

I have triaged open issues related to `git-fetch-with-cli`.

`corrupt_git.rs` is an interesting case. From what an agent told me that
sounds reasonable, we hit an infinite loop in libgit2. We should report
that but not feeling it is bad enough to be a blocker for merging this,
especially since people are using a sparse index.

Future goals:
- Remove git2 fetch to unblock moving off of curl
- Remove git2 to speed up startup and reduce C deps

Future steps:
1. Add future-incompat when the default falls back to git2
1. Remove the `git` check, always defaulting to git-cli
2. Remove git2 fetch
2026-10-03 14:28:34 +00:00
.cargo feat: Add a typos CI job 2025-11-12 10:39:43 -07:00
.github chore(ci): exercise build-rs unstable feature 2026-09-18 23:44:37 -04:00
benches chore: Update imports for workspace rename 2026-07-17 14:14:20 -05:00
ci chore: Move src/doc/ to doc/ 2026-07-17 11:20:52 -05:00
crates test: Added a ReadOnly RAII helper to cargo-test-support 2026-10-02 22:15:19 +09:00
credential chore(deps): update msrv (1 version) to v1.98 2026-08-23 23:25:46 -04:00
doc fix(git)!: Default to net.git-fetch-with-cli if git is present (#17329) 2026-10-03 14:28:34 +00:00
etc refactor: Rename internal content from target-triple to target-tuple 2026-09-29 10:19:51 -05:00
src fix(git)!: Default to net.git-fetch-with-cli if git is present (#17329) 2026-10-03 14:28:34 +00:00
tests fix(git)!: Default to net.git-fetch-with-cli if git is present (#17329) 2026-10-03 14:28:34 +00:00
.git-blame-ignore-revs Ignore rustfmt 2024 commit 2025-07-05 19:51:10 -07:00
.gitignore chore: Move src/doc/ to doc/ 2026-07-17 11:20:52 -05:00
.ignore chore: Move src/doc/ to doc/ 2026-07-17 11:20:52 -05:00
build.rs chore: Move src/doc/ to doc/ 2026-07-17 11:20:52 -05:00
Cargo.lock chore(mem-stats): Bump Cargo.toml versions 2026-10-01 19:24:53 +00:00
Cargo.toml chore(mem-stats): Bump Cargo.toml versions 2026-10-01 19:24:53 +00:00
CHANGELOG.md Fix changelog link 2025-02-04 06:11:14 -08:00
clippy.toml Disallow using stdlib's HashMap/HashSet and IndexMap/IndexSet data structures 2026-07-05 23:06:18 -04:00
CODE_OF_CONDUCT.md Add CoC 2023-01-25 10:18:15 +00:00
CONTRIBUTING.md docs: adopt rust-lang/rust's LLM usage policy 2026-08-07 22:38:46 -04:00
deny.toml Update all dependencies 2025-02-09 15:50:36 -08:00
LICENSE-APACHE HTTPS all the things 2019-01-30 15:34:37 -05:00
LICENSE-MIT Remove inaccurate (misattributed) copyright notices 2017-07-26 17:19:24 -07:00
LICENSE-THIRD-PARTY HTTPS all the things 2019-01-30 15:34:37 -05:00
publish.py refactor(term): Create a no-op cargo-util-terminal 2026-03-27 16:51:48 -05:00
README.md chore: Removed the Code Status section from README.md 2026-09-21 23:49:06 +09:00
rustfmt.toml Rustfmt 2024 2025-07-05 19:50:36 -07:00
triagebot.toml chore: Add Muscraft to the review rotation 2026-09-14 07:57:18 -06:00
typos.toml Remove -Zasymmetric-token / cargo:paseto 2026-09-16 16:26:55 -05:00
windows.manifest.xml Add a windows manifest file 2023-12-07 14:24:58 +00:00

Cargo

Cargo downloads your Rust project’s dependencies and compiles your project.

To start using Cargo, learn more at The Cargo Book.

To start developing Cargo itself, read the Cargo Contributor Guide.

The Cargo binary distributed through with Rust is maintained by the Cargo team for use by the wider ecosystem. For all other uses of this crate (as a binary or library) this is maintained by the Cargo team, primarily for use by Cargo and not intended for external use (except as a transitive dependency). This crate may make major changes to its APIs.

Compiling from Source

Requirements

Cargo requires the following tools and packages to build:

Other requirements:

The following are optional based on your platform and needs.

  • pkg-config — This is used to help locate system packages, such as libssl headers/libraries. This may not be required in all cases, such as using vendored OpenSSL, or on Windows.

  • OpenSSL — Only needed on Unix-like systems and only if the vendored-openssl Cargo feature is not used.

    This requires the development headers, which can be obtained from the libssl-dev package on Ubuntu or openssl-devel with apk or yum or the openssl package from Homebrew on macOS.

    If using the vendored-openssl Cargo feature, then a static copy of OpenSSL will be built from source instead of using the system OpenSSL. This may require additional tools such as perl and make.

    On macOS, common installation directories from Homebrew, MacPorts, or pkgsrc will be checked. Otherwise it will fall back to pkg-config.

    On Windows, the system-provided Schannel will be used instead.

    LibreSSL is also supported.

Optional system libraries:

The build will automatically use vendored versions of the following libraries. However, if they are provided by the system and can be found with pkg-config, then the system libraries will be used instead:

  • libcurl — Used for network transfers.
  • libgit2 — Used for fetching git dependencies.
  • libssh2 — Used for SSH access to git repositories.
  • libz (AKA zlib) — Used by the above C libraries for data compression. (Rust code uses zlib-rs instead.)

It is recommended to use the vendored versions as they are the versions that are tested to work with Cargo.

Compiling

First, you'll want to check out this repository

git clone https://github.com/rust-lang/cargo.git
cd cargo

With cargo already installed, you can simply run:

cargo build --release

Adding new subcommands to Cargo

Cargo is designed to be extensible with new subcommands without having to modify Cargo itself. See the Wiki page for more details and a list of known community-developed subcommands.

Releases

Cargo releases coincide with Rust releases. High level release notes are available as part of Rust's release notes. Detailed release notes are available in the changelog.

Reporting issues

Found a bug? We'd love to know about it!

Please report all issues on the GitHub issue tracker.

Contributing

See the Cargo Contributor Guide for a complete introduction to contributing to Cargo.

Code documentation: https://doc.rust-lang.org/nightly/nightly-rustc/cargo/

License

Cargo is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Third party software

This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (https://www.openssl.org/).

In binary form, this product includes software that is licensed under the terms of the GNU General Public License, version 2, with a linking exception, which can be obtained from the upstream repository.

See LICENSE-THIRD-PARTY for details.