19981 Commits

Author SHA1 Message Date
Arlo Siemsen
b72d6476ae feat(network): use Retry-After header for HTTP 429 responses 2025-05-07 15:44:35 -05:00
Weihang Lo
6cba807e2c
Improved error message for versions prefixed with v (#15484)
### What does this PR try to resolve?

- Added an error message when version in `CRATE[@<VER>]` or `--version
<VER>` starts with 'v' for `install`, `add`, `yank` and `update
--precise <VER>`
- Check if version is valid in `cargo yank`

Fixes #12331

### How should we test and review this PR?

Added tests for each subcommand
2025-05-04 13:44:15 +00:00
Pyrode
2ba61b9dfc update: Added error message for when v is prefixed with version 2025-05-03 22:35:44 +05:30
Pyrode
ef3e28d371 test(update): Added test for prefixed v in version 2025-05-03 22:33:00 +05:30
Pyrode
d07439b7fd yank: Check for bad version & added error message for prefixed v in version 2025-05-03 22:31:08 +05:30
Pyrode
cd27a11da6 test(yank): Added test cases for bad version & prefixed v in version 2025-05-03 22:26:15 +05:30
Pyrode
9ae361a8fe add: Added error message for when v is prefixed with version 2025-05-03 22:25:12 +05:30
Pyrode
ac86dea366 test(add): Added test case for prefixed v in version 2025-05-03 22:24:52 +05:30
Pyrode
7e09951039 install: Added error message for when v is prefixed with version 2025-05-03 22:20:38 +05:30
Pyrode
681597f866 test(install): Added test case for prefixed v in version 2025-05-03 22:19:22 +05:30
Weihang Lo
4b96b302c0
chore: fix some typos in comment (#15485)
<!--
Thanks for submitting a pull request 🎉! Here are some tips for you:

* If this is your first contribution, read "Cargo Contribution Guide"
first:
  https://doc.crates.io/contrib/
* Run `cargo fmt --all` to format your code changes.
* Small commits and pull requests are always preferable and easy to
review.
* If your idea is large and needs feedback from the community, read how:
  https://doc.crates.io/contrib/process/#working-on-large-features
* Cargo takes care of compatibility. Read our design principles:
  https://doc.crates.io/contrib/design.html
* When changing help text of cargo commands, follow the steps to
generate docs:

https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages
* If your PR is not finished, set it as "draft" PR or add "WIP" in its
title.
* It's ok to use the CI resources to test your PR, but please don't
abuse them.

### What does this PR try to resolve?

 fix some typos in comment

### How should we test and review this PR?

Demonstrate how you test this change and guide reviewers through your
PR.
With a smooth review process, a pull request usually gets reviewed
quicker.

If you don't know how to write and run your tests, please read the
guide:
https://doc.crates.io/contrib/tests

### Additional information

Other information you want to mention in this PR, such as prior arts,
future extensions, an unresolved problem, or a TODO list.
-->
2025-05-03 15:50:31 +00:00
whosehang
0e282f77ce chore: fix some typos in comment
Signed-off-by: whosehang <whosehang@outlook.com>
2025-05-03 23:20:53 +08:00
Ed Page
8b5c351550
fix: default to all targets when using --edition and --edition-idioms in cargo fix (#15192)
### What does this PR try to resolve?

Close https://github.com/rust-lang/cargo/issues/13527

As we discussed, `cargo fix` should use the default target selection
with `cargo check`.

In this PR, I modified `cargo fix` to no longer use all targets by
default. For `cargo fix --edition` and `cargo fix --edition-idioms`, it
will retain the old behavior and select all targets.

### How should we test and review this PR?

Unit tests

### Additional information
2025-05-02 14:53:33 +00:00
Weihang Lo
8bf154cfa2
Update fingerprint footnote (#15478)
This was noted in
https://github.com/rust-lang/cargo/issues/8140#issuecomment-2845741150
that it appeared outdated, and indeed this was changed in
https://github.com/rust-lang/cargo/pull/6832.
2025-05-01 22:38:48 +00:00
Eric Huss
f08a7e49e8
Update fingerprint footnote
This was noted in https://github.com/rust-lang/cargo/issues/8140#issuecomment-2845741150 that it appeared outdated, and indeed this was changed in https://github.com/rust-lang/cargo/pull/6832.
2025-05-01 15:04:44 -07:00
Ed Page
64e3cd1ac5
feat(add): suggest similarly named features (#15438)
### What does this PR try to resolve?
Fixes #15436

### How should we test and review this PR?
There are 3 tests for each test case:
- there are no feature suggestions
- there's only one feature suggestion (most common)
- there are several feature suggestions
2025-05-01 14:56:49 +00:00
Ed Page
39b492cc94
In package-workspace, keep dev-dependencies if they have a version (#15470)
Fixes #15412
2025-05-01 14:49:46 +00:00
Ed Page
6ee6027127
docs: fix a typo in DependencyUI (#15472)
<!--
Thanks for submitting a pull request 🎉! Here are some tips for you:

* If this is your first contribution, read "Cargo Contribution Guide"
first:
  https://doc.crates.io/contrib/
* Run `cargo fmt --all` to format your code changes.
* Small commits and pull requests are always preferable and easy to
review.
* If your idea is large and needs feedback from the community, read how:
  https://doc.crates.io/contrib/process/#working-on-large-features
* Cargo takes care of compatibility. Read our design principles:
  https://doc.crates.io/contrib/design.html
* When changing help text of cargo commands, follow the steps to
generate docs:

https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages
* If your PR is not finished, set it as "draft" PR or add "WIP" in its
title.
* It's ok to use the CI resources to test your PR, but please don't
abuse them.

### What does this PR try to resolve?

Explain the motivation behind this change.
A clear overview along with an in-depth explanation are helpful.

You can use `Fixes #<issue number>` to associate this PR to an existing
issue.

### How should we test and review this PR?

Demonstrate how you test this change and guide reviewers through your
PR.
With a smooth review process, a pull request usually gets reviewed
quicker.

If you don't know how to write and run your tests, please read the
guide:
https://doc.crates.io/contrib/tests

### Additional information

Other information you want to mention in this PR, such as prior arts,
future extensions, an unresolved problem, or a TODO list.
-->
2025-05-01 14:29:07 +00:00
Farid Huliiev
ba494bce13
feat: suggest similarly named features 2025-05-01 16:12:36 +02:00
Farid Huliiev
e29810c327
feat: add tests for similarly named features 2025-05-01 16:02:15 +02:00
ELginas
ef4807a439
docs: fix a typo in DependencyUI
Signed-off-by: ELginas <gintaras.z123@yahoo.com>
2025-05-01 14:48:25 +03:00
Joe Neeman
faf7329c4f Only ignore dev-dependencies in dependency order if they have no version 2025-05-01 13:41:00 +07:00
Joe Neeman
54448a1a19 Only check for the registry if package-workspace is turned on.
Without this, the upcoming change to stop stripping versioned
dev-dependencies breaks the unpublished_cyclic_dev_dependencies test
because the test setup replaces the registry.
2025-05-01 13:41:00 +07:00
Joe Neeman
efb300775a Add a failing test 2025-05-01 13:18:40 +07:00
Farid Huliiev
49e2f84edd
fix: output a blank line between items 2025-04-30 19:56:31 +02:00
Ed Page
1649ee28e3
fix grammar, and remove confusing example (#15457)
Also, lots of commands need to contact the registry, so seeing an
example gives me doubt.
2025-04-30 13:55:34 +00:00
Tshepang Mbambo
656263f56d add some clarity... some commands access registry indirectly 2025-04-30 13:06:01 +02:00
Weihang Lo
4a7e88157c
Added tracing spans for rustc invocations (#15464)
### What does this PR try to resolve?

While doing some investigation on the theoretical performance
implications of #4282 (and #15010 by extension) I was profiling cargo
with some experimental changes. (Still a work in progress)

But in the mean time, noticed that we do not have spans for rustc
invocations. I think these would be useful when profiling `cargo build`.
(`cargo build --timing` exists but is more geared towards debugging a
slow building project, not cargo itself)

For reference below is an example before/after of a profile run of a
dummy crate with a few random dependencies.

#### Before

![image](https://github.com/user-attachments/assets/710d1b93-133d-4826-9e7a-2deed876dbfa)

#### After

![image](https://github.com/user-attachments/assets/0f0ccad4-82b5-42ad-8762-6bd1dacecab4)
2025-04-29 17:51:14 +00:00
Ross Sullivan
addc570fab
feat(build): Added tracing spans for rustc invocations 2025-04-29 22:22:05 +09:00
Weihang Lo
2887f07554
Trivial tweaks to 'target_short_hash' (#15461)
### What does this PR try to resolve?

The `target_short_hash` function is a fallback used by the `pkg_dir`
function for units that should not generate `-C extra-filename`.

This makes the function private since it would be easy to misuse and
fixes an outdated method name in the doc comment.

### How should we test and review this PR?

Trivial.
2025-04-29 04:45:01 +00:00
Brian Anderson
8f06c32ea0 Trivial tweaks to 'target_short_hash' 2025-04-28 16:02:14 -06:00
Ed Page
ab15d58608
chore(deps): update msrv (3 versions) to v1.84 (#15456)
This PR contains the following updates:

| Package | Update | Change | Pending |
|---|---|---|---|
| [MSRV:3](https://redirect.github.com/rust-lang/rust) | minor | `1.83`
-> `1.84` | `1.86` (+1) |

---

### Release Notes

<details>
<summary>rust-lang/rust (MSRV:3)</summary>

###
[`v1.84`](https://redirect.github.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1841-2025-01-30)

[Compare
Source](https://redirect.github.com/rust-lang/rust/compare/1.83.0...1.84.0)

\==========================

<a id="1.84.1"></a>

- [Fix ICE 132920 in duplicate-crate
diagnostics.](https://redirect.github.com/rust-lang/rust/pull/133304/)
- [Fix errors for overlapping impls in incremental
rebuilds.](https://redirect.github.com/rust-lang/rust/pull/133828/)
- [Fix slow compilation related to the next-generation trait
solver.](https://redirect.github.com/rust-lang/rust/pull/135618/)
- [Fix debuginfo when LLVM's location discriminator value limit is
exceeded.](https://redirect.github.com/rust-lang/rust/pull/135643/)
-   Fixes for building Rust from source:
- [Only try to distribute `llvm-objcopy` if llvm tools are
enabled.](https://redirect.github.com/rust-lang/rust/pull/134240/)
- [Add Profile Override for Non-Git
Sources.](https://redirect.github.com/rust-lang/rust/pull/135433/)
- [Resolve symlinks of LLVM tool binaries before copying
them.](https://redirect.github.com/rust-lang/rust/pull/135585/)
- [Make it possible to use ci-rustc on tarball
sources.](https://redirect.github.com/rust-lang/rust/pull/135722/)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Every minute ( * * * * * ) (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/rust-lang/cargo).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yNTcuMyIsInVwZGF0ZWRJblZlciI6IjM5LjI1Ny4zIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->
2025-04-28 16:28:20 +00:00
Rustin170506
a6eb2bd334 test: use the correct stats code and do not use --all-targets
Signed-off-by: Rustin170506 <techregister@pm.me>
2025-04-28 23:45:05 +08:00
renovate[bot]
b15a7ccd16
chore(deps): update msrv (3 versions) to v1.84 2025-04-28 15:38:04 +00:00
Ed Page
538c1639ad
feat(add/install): check if given crate argument would be valid with inserted @ symbol (#15441)
Suggest to user to use a crate name with an inserted @ before the first
invalid package name character

Fixes #15318

<!--
Thanks for submitting a pull request 🎉! Here are some tips for you:

* If this is your first contribution, read "Cargo Contribution Guide"
first:
  https://doc.crates.io/contrib/
* Run `cargo fmt --all` to format your code changes.
* Small commits and pull requests are always preferable and easy to
review.
* If your idea is large and needs feedback from the community, read how:
  https://doc.crates.io/contrib/process/#working-on-large-features
* Cargo takes care of compatibility. Read our design principles:
  https://doc.crates.io/contrib/design.html
* When changing help text of cargo commands, follow the steps to
generate docs:

https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages
* If your PR is not finished, set it as "draft" PR or add "WIP" in its
title.
* It's ok to use the CI resources to test your PR, but please don't
abuse them.

### What does this PR try to resolve?

Explain the motivation behind this change.
A clear overview along with an in-depth explanation are helpful.

You can use `Fixes #<issue number>` to associate this PR to an existing
issue.

### How should we test and review this PR?

Demonstrate how you test this change and guide reviewers through your
PR.
With a smooth review process, a pull request usually gets reviewed
quicker.

If you don't know how to write and run your tests, please read the
guide:
https://doc.crates.io/contrib/tests

### Additional information

Other information you want to mention in this PR, such as prior arts,
future extensions, an unresolved problem, or a TODO list.
-->
2025-04-28 15:02:41 +00:00
Weihang Lo
a98aec63d9
chang 1 tries to 1 try (#15328)
### What does this PR try to resolve?
The "1 tries remaining" message is boring, "1 try remaining" seems
better.

### How should we test and review this PR?
Run `cargo update` without network and watch the output messages.
2025-04-28 12:30:03 +00:00
Zhang Wen
776ea25e55 fix the odd info '1 tries remaining' 2025-04-28 13:29:27 +08:00
Tshepang Mbambo
12b68bedd9 fix grammar, and remove confusing example
Lots of commands need to contact the registry,
and seeing an example made me doubt that.
2025-04-27 16:44:26 +02:00
Weihang Lo
7918c7eb59
overriding-dependencies.md: better readability (#15459) 2025-04-27 09:44:23 +00:00
Weihang Lo
6dc7b9d965
source-replacement.md: fix typo (#15458) 2025-04-27 09:43:08 +00:00
Weihang Lo
12555be407
Stabilize automatic garbage collection. (#14287)
This proposes to stabilize automatic garbage collection of Cargo's
global cache data in the cargo home directory.

### What is being stabilized?

This PR stabilizes automatic garbage collection, which is triggered at
most once per day by default. This automatic gc will delete old, unused
files in cargo's home directory.

It will delete files that need to be downloaded from the network after 3
months, and files that can be generated without network access after 1
month. These thresholds are intended to balance the intent of reducing
cargo's disk usage versus deleting too often forcing cargo to do extra
work when files are missing.

Tracking of the last-use data is stored in a sqlite database in the
cargo home directory. Cargo updates timestamps in that database whenever
it accesses a file in the cache. This part is already stabilized.

This PR also stabilizes the `gc.auto.frequency` configuration option.
The primary use case for when a user may want to set that is to set it
to "never" to disable gc should the need arise to avoid it.

When gc is initiated, and there are files to delete, there will be a
progress bar while it is deleting them. The progress bar will disappear
when it finishes. If the user runs with `-v` verbose option, then cargo
will also display which files it deletes.

If there is an error while cleaning, cargo will only display a warning,
and otherwise continue.

### What is not being stabilized?

The manual garbage collection option (via `cargo clean gc`) is not
proposed to be stabilized at this time. That still needs some design
work. This is tracked in
https://github.com/rust-lang/cargo/issues/13060.

Additionally, there are several low-level config options currently
implemented which define the thresholds for when it will delete files. I
think these options are probably too low-level and specific. This is
tracked in https://github.com/rust-lang/cargo/issues/13061.

Garbage collection of build artifacts is not yet implemented, and
tracked in https://github.com/rust-lang/cargo/issues/13136.

### Background

This feature is tracked in
https://github.com/rust-lang/cargo/issues/12633 and was implemented in a
variety of PRs, primarily https://github.com/rust-lang/cargo/pull/12634.

The tests for this feature are located in
https://github.com/rust-lang/cargo/blob/master/tests/testsuite/global_cache_tracker.rs.

Cargo started tracking the last-use data on stable via
https://github.com/rust-lang/cargo/pull/13492 in 1.78 which was released
2024-05-02. This PR is proposing to stabilize automatic deletion in 1.82
which will be released in 2024-10-17.

### Risks

Users who frequently use versions of Rust older than 1.78 will not have
the last-use data tracking updated. If they infrequently use 1.78 or
newer, and use the same cache files, then the last-use tracking will
only be updated by the newer versions. If that time frame is more than 1
month (or 3 months for downloaded data), then cargo will delete files
that the older versions are still using. This means the next time they
run the older version, it will have to re-download or re-extract the
files.

The effects of deleting cache data in environments where cargo's cache
is modified by external tools is not fully known. For example, CI
caching systems may save and restore cargo's cache. Similarly, things
like Docker images that try to save the cache in a layer, or mount the
cache in a read-only filesystem may have undesirable interactions.

The once-a-day performance hit might be noticeable to some people. I've
been using this for several months, and almost never notice it. However,
slower systems, or situations where there is a lot of data to delete
might take a while (on the order of seconds hopefully).
2025-04-27 09:38:21 +00:00
Tshepang Mbambo
6ad4460977
overriding-dependencies.md: better readability 2025-04-27 01:30:55 +02:00
dawe
0df8d68cf9
feat(add): check if given crate argument would be valid with inserted @ symbol, suggest fixed argument 2025-04-27 01:23:51 +02:00
dawe
98326ac0f5
feat(install): check if given crate argument would be valid with inserted @ symbol, suggest fixed argument 2025-04-27 01:23:48 +02:00
dawe
ab0d6a7bd2
test(add): add test to show current behaviour of cargo add when @ symbol is missing for the version 2025-04-27 01:23:26 +02:00
Tshepang Mbambo
733d6a665a
source-replacement.md: fix typo 2025-04-27 01:20:35 +02:00
dawe
77f54cc658
test(add): add test to show current behaviour of cargo install when @ symbol is missing for the version 2025-04-26 22:01:38 +02:00
Weihang Lo
ee85adae45
Update doctest xcompile flags (#15455)
This updates the flags used for doctest xcompile to match the upstream
changes in https://github.com/rust-lang/rust/pull/137096 which renamed
and stabilized the flags.

This cannot be merged until after nightly is published tonight.
2025-04-26 13:35:28 +00:00
Eric Huss
f10630f2bf Update doctest xcompile flags
This updates the flags used for doctest xcompile to match the upstream
changes in https://github.com/rust-lang/rust/pull/137096 which renamed
and stabilized the flags.
2025-04-26 06:07:27 -07:00
Ed Page
fb3906d3ab
fix: Suggest similar looking feature names when feature is missing (#15454)
### What does this PR try to resolve?

I recently depended on a package with `preserve-order` rather than
`preserve_order` and the error message didn't help me with the problem
so I figure I'd fix that. I also found other improvements along the way

- Suggest an alternative feature when a feature includes a missing
feature
- Suggest an alternative feature when a dependency includes a missing
feature
- Lower case error messages
- Re-frame prescriptive information as help
- Change plural "features" error messages to singular "feature" as they
can only ever have one (knowing an the `MissingFeature` string only has
one feature in it was important for doing a `closest` match on the
feature).

### How should we test and review this PR?

### Additional information
2025-04-25 19:45:13 +00:00