13386 Commits

Author SHA1 Message Date
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
hi-rustin
3c40d6194d Error when precise or aggressive without -p flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-08 09:11:25 +08:00
bors
0a979d3f70 Auto merge of #11342 - weihanglo:issue/11330-new-test, r=ehuss
test(features2): test to prevent regressing of optional host deps of dep
2022-11-07 20:50:34 +00:00
Weihang Lo
e295a1056e
test(features2): test to prevent regressing of optional host deps of dep 2022-11-07 17:42:05 +00:00
bors
df56877805 Auto merge of #11340 - weihanglo:version-bump, r=ehuss
Bump to 0.68.0, update changelog
2022-11-05 18:33:48 +00:00
Weihang Lo
1b4c1335f4
Update changelog for 1.67 2022-11-05 17:58:08 +00:00
Weihang Lo
b2bf664259
Update changelog for 1.66 2022-11-05 17:58:08 +00:00
Weihang Lo
a3d4cd4732
Bump to 0.68.0 2022-11-05 00:41:09 +00:00
Weihang Lo
de7cd31eac
aware of compression ratio for unpack size limit 2022-11-04 18:40:44 +00:00
bors
9286a1beba Auto merge of #11328 - epage:upgrade, r=weihanglo
chore: Upgrade dependencies

This upgrades several dependencies to the latest "major" release.  The original intent was just to get onto the latest snapbox but I noticed several others that could be updated and thought "why not".

- `snapbox` broke compatibility on less used APIs
- Its unclear from the docs if `miow` or `remove_dir_all` even broke compatibility

I did not touch `mdman` as that has several large, stale deps
2022-11-04 06:41:49 +00:00
bors
d95124ee93 Auto merge of #11335 - ehuss:space-test, r=epage
Clean more aggressively in CI

The Windows x86_64 gnu CI job is running dangerously low on disk space. This PR adds another step to delete test output more aggressively. The test output with x86_64-pc-windows-gnu is nearly 9.5GB. The benchmark step is adding about 1GB of space (unfortunately it is rebuilding cargo, which may be hard to avoid without a workspace).

Eventually we should probably look at figuring out how to reduce the amount of disk space used by the testsuite. Perhaps something like #9701 (see comments there). Or, making aggressive changes to the tests themselves. Many tests can probably be changed to use `cargo check` instead of `cargo build` (or maybe even `cargo tree`). We can default to not generating debuginfo. Or perhaps there are other changes to put the tests on a diet.
2022-11-04 03:26:49 +00:00
Eric Huss
3a404ce49e Clean more aggressively in CI 2022-11-03 20:12:03 -07:00
bors
180ad9157c Auto merge of #11333 - ehuss:remove-remove_dir_all, r=epage
Remove remove_dir_all

This removes the `remove_dir_all` dependency. It is no longer needed, as there has been significant improvements to std's implementation over the years (particularly recently). This improves the performance of running cargo's testsuite on my machine from 8m to 2m 30s (!!).

This was added in #7137 to deal with some issues with symbolic links. I believe those seem to be resolved now.

Note that std's implementation is still not bullet proof. In particular, I think there are still some cases where a file can be locked by another process which prevents it from being removed. There are some more notes about this at https://github.com/rust-lang/cargo/pull/7042#issuecomment-504081900 (and various other places linked there).

Closes #9585
2022-11-04 01:06:42 +00:00
Ed Page
8d6a828c18 chore: Upgrade miow 2022-11-03 19:59:25 -05:00
bors
68e9d6c17b Auto merge of #11327 - epage:wait, r=ehuss
test(publish): Cover more wait-for-publish cases

These came from trying to guess what cases are causing problems in #11314.  Unfortunately, can't reproduce it so far but figured it'd be good to keep these around.
2022-11-04 00:04:29 +00:00
Eric Huss
fa8375b3c9 Remove remove_dir_all 2022-11-03 16:51:48 -07:00
bors
7d8d028430 Auto merge of #11331 - weihanglo:revert-11183, r=ehuss
Revert #11183

This reverts commit d4c38af1202c8b24fce6b2ad170c520017e059b9, reversing changes made to 92d8826ed4b7dfd5dd60c75bcc86da4032b00899.

Fixes #11330

---

The root cause is that [`map_to_features_for`] takes care of `unit_for.host_features` from parent unit, but [here] we only want to know whether the dependency is for host or not.

We could have an ad-hoc `FeaturesFor` construction there, but I'd rather revert it at this moment. The interaction between `UnitFor` and `FeaturesFor` bites me every time 😭.

After this revert, if we want to resolve #10526 again. The fastest way is doing the following:

```diff
diff --git a/src/cargo/core/compiler/unit_dependencies.rs b/src/cargo/core/compiler/unit_dependencies.rs
index 9319a19e0..14cc84941 100644
--- a/src/cargo/core/compiler/unit_dependencies.rs
+++ b/src/cargo/core/compiler/unit_dependencies.rs
`@@` -1103,7 +1103,7 `@@` impl<'a, 'cfg> State<'a, 'cfg> {
                         // If this is an optional dependency, and the new feature resolver
                         // did not enable it, don't include it.
                         if dep.is_optional() {
-                            let features_for = unit_for.map_to_features_for(dep.artifact());
+                            let features_for = FeaturesFor::from_for_host(unit_for.is_for_host());
                             if !self.is_dep_activated(pkg_id, features_for, dep.name_in_toml()) {
                                 return false;
                             }
```

[`map_to_features_for`]: 810cbad9a1/src/cargo/core/profiles.rs (L1043)
[here]: 810cbad9a1/src/cargo/core/compiler/unit_dependencies.rs (L1102)
2022-11-03 21:25:08 +00:00
bors
2d70754738 Auto merge of #11332 - weihanglo:fix-semver-check, r=Muscraft
fix(semver-check): adapt to a different error for variant not covered
2022-11-03 19:18:42 +00:00
Weihang Lo
bc16cdb5fb
fix(semver-check): adapt to a different error for variant not covered 2022-11-03 16:38:58 +00:00
Weihang Lo
5fe27327c3
Revert "Auto merge of #11183 - weihanglo:issue/10526, r=ehuss"
This reverts commit d4c38af1202c8b24fce6b2ad170c520017e059b9, reversing
changes made to 92d8826ed4b7dfd5dd60c75bcc86da4032b00899.
2022-11-03 15:08:30 +00:00
hi-rustin
62bfdf0da1 Remove unreachable branches
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-03 20:43:45 +08:00
Ed Page
25f838bfb7 chore: Upgrade snapbox 2022-11-02 23:15:48 -05:00
Ed Page
d87966b466 test(publish): Require extra waits 2022-11-02 16:42:14 -05:00
bors
810cbad9a1 Auto merge of #11326 - ehuss:bump-curl, r=weihanglo
Update curl-sys

This updates curl-sys which pulls in https://github.com/alexcrichton/curl-rust/pull/472 which should fix the build errors with clang.
2022-11-02 21:04:31 +00:00
Eric Huss
d3a208a9b5 Update curl-sys 2022-11-02 13:03:11 -07:00
Ed Page
6998fb3896 test(publish): Verify updating existing entries works 2022-11-02 10:39:21 -05:00