Commit graph

13311 commits

Author SHA1 Message Date
hi-rustin a3eb31fab4 Fix typo try use -> try to use
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-20 18:14:17 +08:00
bors 63fdd75bde Auto merge of #11377 - hi-rustin:rustin-patch-warning-tree, r=weihanglo
Add warning when `cargo tree -i <spec>` can not find packages

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11315

Add warning when `cargo tree -i <spec>` can not find packages.

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

Please run the unit test.
2022-11-20 08:52:04 +00:00
hi-rustin c5eb61823c Remove the --all-features tip
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-20 16:39:00 +08:00
bors 43689d353a Auto merge of #11194 - cassaundra:cargo-remove-gc, r=epage
Clean profile, patch, and replace in cargo remove

### What does this PR try to resolve?

This PR is part of the continued work on cargo remove (#11099, see deferred work).

After a successful removal of a dependency, clean up the profile, patch, and replace sections to remove all references to it.

**Note** the GC process was expanded to clean up not just references to the dependencies just removed, but also references of all dependencies. This was because there's not an easy way to determine which dependencies correspond to the given TOML keys, without either 1) figuring that out before the removal (therefore having to predict the behavior), or 2) returning that information from the remove function (somewhat unorthodox for an op).

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

Verify that the implementation makes sense and that the tests are sufficient.
2022-11-19 02:46:46 +00:00
bors fa85418a65 Auto merge of #11391 - Expyron:master, r=ehuss
chore: Upgrade miow

Upgrade `miow` to the latest release.

The main change from miow is the upgrade of transitive dependency `windows-sys` from 0.28 to 0.42, which removes a duplicate dependency for cargo.
2022-11-18 21:57:25 +00:00
Cassaundra Smith 299252c78d Clean profile, patch, and replace in cargo remove
After a successful removal of a dependency, clean up the profile, patch, and
replace sections to remove all references to the dependency.
2022-11-18 09:33:37 -06:00
Expyron bb837662d8 chore: Upgrade miow 2022-11-18 14:08:46 +01:00
bors eb5d35917b Auto merge of #11388 - arlosi:fix-waiting-tests, r=epage
Fix several tests that are waiting 60 seconds for publishing to time out

Several tests are missing the pre-publishing hack to avoid the 60 second wait-for-publish timeout.

r? `@epage`
2022-11-17 22:08:43 +00:00
Arlo Siemsen 7cd613773d Fix several tests that are waiting 60 seconds for publishing to time out 2022-11-17 15:54:24 -06:00
Arlo Siemsen 1da79baf54 Store the sparse+ prefix in the URL for sparse registries 2022-11-17 14:25:47 -06:00
bors 4d5c036a00 Auto merge of #10592 - arlosi:auth, r=ehuss
Implement RFC 3139: alternative registry authentication support

Allows registries to request Cargo to send the authentication token for all requests, rather than just publish/yank, implementing [RFC 3139](https://github.com/rust-lang/cargo/issues/10474).

### Items from the [tracking issue](https://github.com/rust-lang/cargo/issues/10474)

> Do registries need a more fine-grained switch for which API commands require authentication?

This PR uses the `auth_required` boolean as described in the RFC.

> The RFC mentions adding --token to additional commands like install and search

These flags are not added by this PR.

> Consider changing the name and form of the X- header

Changed to the `www-authenticate` header as suggested by the comments.

> Will there be any concerns with the interaction with https://github.com/rust-lang/rfcs/pull/3231

Not that I know of.

-------------

Adds a new field `"auth-required": true` to `config.json` that indicates Cargo should include the token in all requests to a registry.

For HTTP registries, Cargo first attempts an un-authenticated request, then if that fails with HTTP 401, an authenticated request is attempted. The registry server may include a `www-authenticate` header with the HTTP 401 to instruct Cargo with URL the user can visit to acquire a token (crates.io/me).

Since the API URL is not known (because it's stored in the index), the unstable credential provider feature is modified to key off the index url, and the registry name is no longer provided.

To handle the case where an alternative registry's name is not known (such as coming from a lock file, or via `--index`), Cargo can now look up the token in the configuration by matching on the index URL. This introduces a new error if two alternative registries are configured with the same index URL.

Several operations, such as `cargo install` could have had a `--token` argument added, however it appears that Cargo would like to move away from passing the token on the command line for security reasons. In this case, users would need to configure the registry via the config file (or environment variables) when using `cargo install --index ...` or similar.
2022-11-17 01:25:35 +00:00
Arlo Siemsen 9827412fee Implement RFC 3139: alternative registry authentication support 2022-11-16 14:36:19 -06:00
Will Crichton b325a8d5d5 Fix complex_reverse_dependencies test 2022-11-16 09:18:37 -08:00
Will Crichton 39e6737de7 Change rustdoc-scrape-examples to be a target-level configuration 2022-11-16 09:18:33 -08:00
bors b690ab48fc Auto merge of #11302 - arlosi:install-default, r=weihanglo
Fix cargo install --index when used with registry.default

Setting `registry.default` causes the `args.registry` call to return the default registry as if it were passed through `--registry`, which leaves the `--index` argument ignored in `cargo install`, since `registry` is checked first.

Fixes #11301 by checking for `index` before `registry`.

Note that if you try to pass both `--index` and `--registry`, then a command-line parser error (correctly) occurs:
```
The argument '--registry <REGISTRY>' cannot be used with '--index <INDEX>'
```
2022-11-16 12:03:34 +00:00
Arlo Siemsen 24bf873c83 Fix cargo install --index when used with registry.default 2022-11-15 11:28:29 -06:00
hi-rustin a4f89eab03 Add warning when cargo tree -i <spec> can not find packages
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-15 09:41:39 +08:00
bors 16b097879b Auto merge of #11375 - xxchan:xxchan/experienced-limpet, r=epage
improve error message for cargo add/remove

### What does this PR try to resolve?

When I see the old error:
```
> cargo add paste
error: 2 packages selected.  Please specify one with `-p <PKGID>`
```
I was a little bit confused, and thought it says there are 2 packages called "paste". The new message is similar to `cargo run`
2022-11-14 23:28:16 +00:00
xxchan a858cc6c4a improve error message for cargo add/remove 2022-11-14 20:32:09 +01:00
bors 26f4c03661 Auto merge of #11369 - weihanglo:bump-versions, r=epage
Bump crate versions of `cargo-util` and `crates-io`
2022-11-14 13:54:36 +00:00
bors 4754751c4e Auto merge of #11373 - weihanglo:changelog, r=epage
doc(changelog): suggestions of cargo fix are nightly only
2022-11-14 12:42:35 +00:00
Weihang Lo 1b54716b15
doc(changelog): suggestions of cargo fix are nightly only 2022-11-14 11:07:44 +00:00
Weihang Lo 7dc316e0ba
chore: upgrade cargo-util and crates-io 2022-11-13 11:00:55 +00:00
Weihang Lo 054a19ba2f
Bump crate crates-io to 0.35.0 2022-11-13 10:55:15 +00:00
Weihang Lo 851492c788
Bump crate cargo-util to 0.2.3 2022-11-13 10:55:10 +00:00
bors 64e46b080e Auto merge of #11318 - RyanAD:3736-improve-invalid-char-error, r=weihanglo
Add warning when PATH env separator is in project path

Closes #3736

Adds a check during `cargo init` and `cargo new` to check if the path contains an invalid PATH character (`:`, `;`, or `"`). These characters can break things in various ways (including `cargo test`). These characters are not valid in certain environment variables and cannot be escaped.

For more information see:
7feb003882/library/std/src/sys/unix/os.rs (L233)
https://man7.org/linux/man-pages/man8/ld.so.8.html
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
https://doc.rust-lang.org/std/env/fn.join_paths.html#errors

To test cargo new and cargo init:
`cargo new --name testing test:ing`
`mkdir test:ing2 && cd 'test:ing2' && cargo init --name testing`

To test the updated error message when in a directory with invalid characters:
`cargo new testing3 && mv testing3 test:ing3 && cd 'test:ing3' && cargo test`

cc `@weihanglo`
2022-11-13 09:16:11 +00:00
David Tolnay 9d7a3b232d
Fix failure to parse rustc's JSON output if it is too nested 2022-11-12 21:15:48 -08:00
RyanAD eb8d3e2932 simplify join_paths error message and add test 2022-11-12 18:44:22 -07:00
RyanAD f1fed1b294 keep empty test directory 2022-11-12 18:43:47 -07:00
RyanAD 730e8ca46d make call to paths::join_paths and warn if path contains invalid chars 2022-11-12 18:43:46 -07:00
RyanAD 23c1a51ad0 Improve error message in join_paths when env contains a path separator 2022-11-12 18:43:37 -07:00
RyanAD 82a92a203c Warn if project path contains an invalid PATH env character 2022-11-12 18:43:35 -07:00
bors f5cdfa4d8b Auto merge of #11366 - ehuss:fix-safe-directory, r=epage
Fix git2 safe-directory disable

The call to `set_verify_owner_validation` was not getting called unless a network configuration was found. This means in the common case that `cargo new` will fail when there is a safe-directory error. This fixes the issue by making sure that `set_verify_owner_validation` is called before the early-exits in `init_git_transports`.

Fixes #11365
2022-11-12 20:31:11 +00:00
Eric Huss 632da896fb Fix git2 safe-directory disable 2022-11-12 08:12:10 -08:00
bors a3dfea71ca Auto merge of #11321 - FrankYang0529:fix-11311, r=epage
fix: return non UTF-8 error message

Fixes https://github.com/rust-lang/cargo/issues/11311

### Test Steps

1. Create a new empty Git repository
2. Create a `.gitignore` that is not valid UTF-8, for instance `printf '\xFF\xFE' > .gitignore`
3. `cargo init`
2022-11-11 03:50:47 +00:00
Frank Yang b98c534d57
fix: return non UTF-8 error message
Signed-off-by: Frank Yang <yangpoan@gmail.com>
2022-11-10 23:49:08 +08:00
bors c8b090c3d4 Auto merge of #11358 - hi-rustin:rustin-patch-error-msg, r=weihanglo
Extract `two_kinds_of_msg_format_err` message to de-duplicate it

### What does this PR try to resolve?

Extract `two_kinds_of_msg_format_err` message to de-duplicate it.

I guess this would be helpful for changing this message.

### Additional information

Just found it when I read the code. So if you prefer the former code style, please feel free to close my PR.
2022-11-10 08:52:44 +00:00
bors 9865dde6d0 Auto merge of #11353 - weihanglo:issue/10527, r=epage
Propagate change of artifact bin dep to its parent fingerprint
2022-11-10 02:30:46 +00:00
hi-rustin 9060360418 Extract two_kinds_of_msg_format_err message to de-duplicate it
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-10 09:50:29 +08:00
bors ffb6ee98f5 Auto merge of #11357 - hi-rustin:rustin-patch-warnings, r=ehuss
Fix not a hyperlink warnings

### What does this PR try to resolve?
Fix not a hyperlink warnings.
```log
warning: this URL is not a hyperlink
   --> crates/cargo-util/src/process_builder.rs:206:11
    |
206 |     /// - https://doc.rust-lang.org/rustdoc/command-line-arguments.html#path-load-command-line-flags-from-a-path
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://doc.rust-lang.org/rustdoc/command-line-arguments.html#path-load-command-line-flags-from-a-path>`
    |
    = note: `#[warn(rustdoc::bare_urls)]` on by default
    = note: bare URLs are not automatically turned into clickable links

warning: this URL is not a hyperlink
   --> crates/cargo-util/src/process_builder.rs:207:11
    |
207 |     /// - https://doc.rust-lang.org/rustc/command-line-arguments.html#path-load-command-line-flags-from-a-path>
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://doc.rust-lang.org/rustc/command-line-arguments.html#path-load-command-line-flags-from-a-path>`
    |
    = note: bare URLs are not automatically turned into clickable links

warning: `cargo-util` (lib doc) generated 2 warnings
```

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

`cargo doc --open`
2022-11-10 01:07:40 +00:00
hi-rustin 6de9ed11be Fix not a hyperlink warnings
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-10 08:52:32 +08:00
bors 0756938501 Auto merge of #11356 - arlosi:sparse-publish, r=epage
Fix wait-for-publish with sparse registry

The `wait-for-publish` feature doesn't work when publishing a new version of an existing crate on a sparse registry.

The `invalidate_cache` method doesn't clear the `fresh` list, so repeated requests just use the in-memory data if it's available. This didn't show up in the tests, because the test only simulated the `not found` to `crate available` transition, rather than the `old file` to `crate available` transition.

This change modifies the test by capturing the publish request, then deferring it until after later request for the index file.

r? `@epage`

Fixes #11314
2022-11-09 23:15:42 +00:00
Weihang Lo 347523e163
fix(fingerprint): include bin target if it is also an artifact dep 2022-11-09 17:44:17 +00:00
Weihang Lo 58e86d4d94
test(bindeps): recompile when bin target is also artifact dep
This records the WRONG behaviour, which parent fingerpint cannot detect
change of a dependency if it is a bin target and also a artifact dep.
2022-11-09 16:29:15 +00:00
Arlo Siemsen 90c6b5854d Fix waiting for publishing to complete when publishing to a sparse registry 2022-11-08 18:14:52 -06:00
bors 5ccea519d4 Auto merge of #11351 - hi-rustin:rustin-patch-alias-docs, r=weihanglo
Add `rm` alias to configuration docs

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11348

Add `rm` alias to configuration docs.

r? `@weihanglo`
2022-11-08 21:39:05 +00:00
bors 3115dd69fd Auto merge of #11350 - hi-rustin:rustin-patch-sparse-docs, r=ehuss
Add `registries.crates-io.protocol` docs

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11343.

Add `registries.crates-io.protocol` docs to explain this unstable option.
2022-11-08 16:00:22 +00:00
hi-rustin 71e4dbd496 Update tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-08 10:00:10 +08:00
hi-rustin 381f9c8c80 Add rm alias to configuration docs
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-08 09:37:23 +08:00
hi-rustin 92dd6f37f9 Add registries.crates-io.protocol docs
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-08 09:30:22 +08:00