Skip to content

Commit 602f1a5

Browse files
committed
Auto merge of #11862 - weihanglo:doc-yank, r=<try>
doc: clarify implications of `cargo-yank` ### What does this PR try to resolve? I found the documentation for `cargo yank` was not especially clear on the implications of yanking a crate, and I have seen this causing confusion within the community - tafia/quick-xml#475. On a somewhat related note, I have been observing lots more crates getting yanked recently and this is resulting in a fair amount of dependency upgrade busywork. I think/hope part of this is a documentation issue.
2 parents b1dcb62 + 5e55cfc commit 602f1a5

File tree

4 files changed

+235
-12
lines changed

4 files changed

+235
-12
lines changed

src/doc/man/cargo-yank.md

+50-3
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,63 @@ The yank command removes a previously published crate's version from the
1515
server's index. This command does not delete any data, and the crate will
1616
still be available for download via the registry's download link.
1717

18-
Note that existing crates locked to a yanked version will still be able to
19-
download the yanked version to use it. Cargo will, however, not allow any new
20-
crates to be locked to any yanked version.
18+
Cargo will not use a yanked version for any new project or checkout without a
19+
pre-existing lockfile, and will generate an error if there are no longer
20+
any compatible versions for your crate.
2121

2222
This command requires you to be authenticated with either the `--token` option
2323
or using {{man "cargo-login" 1}}.
2424

2525
If the crate name is not specified, it will use the package name from the
2626
current directory.
2727

28+
### How yank works
29+
30+
For example, the `foo` crate published version `1.5.0` and another crate `bar`
31+
declared a dependency on version `foo = "1.5"`. Now `foo` releases a new, but
32+
not semver compatible, version `2.0.0`, and finds a critical issue with `1.5.0`.
33+
If `1.5.0` is yanked, no new project or checkout without an existing lockfile
34+
will be able to use crate `bar` as it relies on `1.5`.
35+
36+
In this case, the maintainers of `foo` should first publish a semver compatible
37+
version such as `1.5.1` prior to yanking `1.5.0` so that `bar` and all projects
38+
that depend on `bar` will continue to work.
39+
40+
As another example, consider a crate `bar` with published versions `1.5.0`,
41+
`1.5.1`, `1.5.2`, `2.0.0` and `3.0.0`. The following table identifies the
42+
versions cargo could use in the absence of a lockfile for different SemVer
43+
requirements, following a given release being yanked:
44+
45+
| Yanked Version / SemVer requirement | `bar = "1.5.0"` | `bar = "=1.5.0"` | `bar = "2.0.0"` |
46+
|-------------------------------------|-----------------------------------------|------------------|------------------|
47+
| `1.5.0` | Use either `1.5.1` or `1.5.2` | **Return Error** | Use `2.0.0` |
48+
| `1.5.1` | Use either `1.5.0` or `1.5.2` | Use `1.5.0` | Use `2.0.0` |
49+
| `2.0.0` | Use either `1.5.0`, `1.5.1` or `0.22.2` | Use `1.5.0` | **Return Error** |
50+
51+
### When to yank
52+
53+
Crates should only be yanked in exceptional circumstances, for example, an
54+
accidental publish, an unintentional SemVer breakages, or a significantly
55+
broken and unusable crate. In the case of security vulnerabilities, [RustSec]
56+
is typically a less disruptive mechanism to inform users and encourage them
57+
to upgrade, and avoids the possibility of significant downstream disruption
58+
irrespective of susceptibility to the vulnerability in question.
59+
60+
A common workflow is to yank a crate having already published a semver
61+
compatible version, to reduce the probability of preventing dependent
62+
crates from compiling.
63+
64+
To address copyright, licensing, or personal data issues with your published
65+
crate, contact the maintainers of the registry you used. For crates.io, refer
66+
to their [policies] and contact them at <[email protected]>.
67+
68+
If your credentials have been leaked, the recommended process is to revoke them
69+
immediately. Once a crate is published, it's impossible to know if those leaked
70+
credentials have been copied, so taking swift action is crucial.
71+
72+
[RustSec]: https://rustsec.org/
73+
[policies]: https://crates.io/policies
74+
2875
## OPTIONS
2976

3077
### Yank Options

src/doc/man/generated_txt/cargo-yank.txt

+56-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,69 @@ DESCRIPTION
1313
crate will still be available for download via the registry’s download
1414
link.
1515

16-
Note that existing crates locked to a yanked version will still be able
17-
to download the yanked version to use it. Cargo will, however, not allow
18-
any new crates to be locked to any yanked version.
16+
Cargo will not use a yanked version for any new project or checkout
17+
without a pre-existing lockfile, and will generate an error if there are
18+
no longer any compatible versions for your crate.
1919

2020
This command requires you to be authenticated with either the --token
2121
option or using cargo-login(1).
2222

2323
If the crate name is not specified, it will use the package name from
2424
the current directory.
2525

26+
How yank works
27+
For example, the foo crate published version 1.5.0 and another crate bar
28+
declared a dependency on version foo = "1.5". Now foo releases a new,
29+
but not semver compatible, version 2.0.0, and finds a critical issue
30+
with 1.5.0. If 1.5.0 is yanked, no new project or checkout without an
31+
existing lockfile will be able to use crate bar as it relies on 1.5.
32+
33+
In this case, the maintainers of foo should first publish a semver
34+
compatible version such as 1.5.1 prior to yanking 1.5.0 so that bar and
35+
all projects that depend on bar will continue to work.
36+
37+
As another example, consider a crate bar with published versions 1.5.0,
38+
1.5.1, 1.5.2, 2.0.0 and 3.0.0. The following table identifies the
39+
versions cargo could use in the absence of a lockfile for different
40+
SemVer requirements, following a given release being yanked:
41+
42+
+------------------------+----------------------+----------+----------+
43+
| Yanked Version / | bar = "1.5.0" | bar = | bar = |
44+
| SemVer requirement | | "=1.5.0" | "2.0.0" |
45+
+------------------------+----------------------+----------+----------+
46+
| 1.5.0 | Use either 1.5.1 or | Return | Use |
47+
| | 1.5.2 | Error | 2.0.0 |
48+
+------------------------+----------------------+----------+----------+
49+
| 1.5.1 | Use either 1.5.0 or | Use | Use |
50+
| | 1.5.2 | 1.5.0 | 2.0.0 |
51+
+------------------------+----------------------+----------+----------+
52+
| 2.0.0 | Use either 1.5.0, | Use | Return |
53+
| | 1.5.1 or 0.22.2 | 1.5.0 | Error |
54+
+------------------------+----------------------+----------+----------+
55+
56+
When to yank
57+
Crates should only be yanked in exceptional circumstances, for example,
58+
an accidental publish, an unintentional SemVer breakages, or a
59+
significantly broken and unusable crate. In the case of security
60+
vulnerabilities, RustSec <https://rustsec.org/> is typically a less
61+
disruptive mechanism to inform users and encourage them to upgrade, and
62+
avoids the possibility of significant downstream disruption irrespective
63+
of susceptibility to the vulnerability in question.
64+
65+
A common workflow is to yank a crate having already published a semver
66+
compatible version, to reduce the probability of preventing dependent
67+
crates from compiling.
68+
69+
To address copyright, licensing, or personal data issues with your
70+
published crate, contact the maintainers of the registry you used. For
71+
crates.io, refer to their policies <https://crates.io/policies> and
72+
contact them at <[email protected]>.
73+
74+
If your credentials have been leaked, the recommended process is to
75+
revoke them immediately. Once a crate is published, it’s impossible to
76+
know if those leaked credentials have been copied, so taking swift
77+
action is crucial.
78+
2679
OPTIONS
2780
Yank Options
2881
--vers version, --version version

src/doc/src/commands/cargo-yank.md

+50-3
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,63 @@ The yank command removes a previously published crate's version from the
1515
server's index. This command does not delete any data, and the crate will
1616
still be available for download via the registry's download link.
1717

18-
Note that existing crates locked to a yanked version will still be able to
19-
download the yanked version to use it. Cargo will, however, not allow any new
20-
crates to be locked to any yanked version.
18+
Cargo will not use a yanked version for any new project or checkout without a
19+
pre-existing lockfile, and will generate an error if there are no longer
20+
any compatible versions for your crate.
2121

2222
This command requires you to be authenticated with either the `--token` option
2323
or using [cargo-login(1)](cargo-login.html).
2424

2525
If the crate name is not specified, it will use the package name from the
2626
current directory.
2727

28+
### How yank works
29+
30+
For example, the `foo` crate published version `1.5.0` and another crate `bar`
31+
declared a dependency on version `foo = "1.5"`. Now `foo` releases a new, but
32+
not semver compatible, version `2.0.0`, and finds a critical issue with `1.5.0`.
33+
If `1.5.0` is yanked, no new project or checkout without an existing lockfile
34+
will be able to use crate `bar` as it relies on `1.5`.
35+
36+
In this case, the maintainers of `foo` should first publish a semver compatible
37+
version such as `1.5.1` prior to yanking `1.5.0` so that `bar` and all projects
38+
that depend on `bar` will continue to work.
39+
40+
As another example, consider a crate `bar` with published versions `1.5.0`,
41+
`1.5.1`, `1.5.2`, `2.0.0` and `3.0.0`. The following table identifies the
42+
versions cargo could use in the absence of a lockfile for different SemVer
43+
requirements, following a given release being yanked:
44+
45+
| Yanked Version / SemVer requirement | `bar = "1.5.0"` | `bar = "=1.5.0"` | `bar = "2.0.0"` |
46+
|-------------------------------------|-----------------------------------------|------------------|------------------|
47+
| `1.5.0` | Use either `1.5.1` or `1.5.2` | **Return Error** | Use `2.0.0` |
48+
| `1.5.1` | Use either `1.5.0` or `1.5.2` | Use `1.5.0` | Use `2.0.0` |
49+
| `2.0.0` | Use either `1.5.0`, `1.5.1` or `0.22.2` | Use `1.5.0` | **Return Error** |
50+
51+
### When to yank
52+
53+
Crates should only be yanked in exceptional circumstances, for example, an
54+
accidental publish, an unintentional SemVer breakages, or a significantly
55+
broken and unusable crate. In the case of security vulnerabilities, [RustSec]
56+
is typically a less disruptive mechanism to inform users and encourage them
57+
to upgrade, and avoids the possibility of significant downstream disruption
58+
irrespective of susceptibility to the vulnerability in question.
59+
60+
A common workflow is to yank a crate having already published a semver
61+
compatible version, to reduce the probability of preventing dependent
62+
crates from compiling.
63+
64+
To address copyright, licensing, or personal data issues with your published
65+
crate, contact the maintainers of the registry you used. For crates.io, refer
66+
to their [policies] and contact them at <[email protected]>.
67+
68+
If your credentials have been leaked, the recommended process is to revoke them
69+
immediately. Once a crate is published, it's impossible to know if those leaked
70+
credentials have been copied, so taking swift action is crucial.
71+
72+
[RustSec]: https://rustsec.org/
73+
[policies]: https://crates.io/policies
74+
2875
## OPTIONS
2976

3077
### Yank Options

src/etc/man/cargo-yank.1

+79-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,91 @@ The yank command removes a previously published crate\[cq]s version from the
1414
server\[cq]s index. This command does not delete any data, and the crate will
1515
still be available for download via the registry\[cq]s download link.
1616
.sp
17-
Note that existing crates locked to a yanked version will still be able to
18-
download the yanked version to use it. Cargo will, however, not allow any new
19-
crates to be locked to any yanked version.
17+
Cargo will not use a yanked version for any new project or checkout without a
18+
pre\-existing lockfile, and will generate an error if there are no longer
19+
any compatible versions for your crate.
2020
.sp
2121
This command requires you to be authenticated with either the \fB\-\-token\fR option
2222
or using \fBcargo\-login\fR(1).
2323
.sp
2424
If the crate name is not specified, it will use the package name from the
2525
current directory.
26+
.SS "How yank works"
27+
For example, the \fBfoo\fR crate published version \fB1.5.0\fR and another crate \fBbar\fR
28+
declared a dependency on version \fBfoo = "1.5"\fR\&. Now \fBfoo\fR releases a new, but
29+
not semver compatible, version \fB2.0.0\fR, and finds a critical issue with \fB1.5.0\fR\&.
30+
If \fB1.5.0\fR is yanked, no new project or checkout without an existing lockfile
31+
will be able to use crate \fBbar\fR as it relies on \fB1.5\fR\&.
32+
.sp
33+
In this case, the maintainers of \fBfoo\fR should first publish a semver compatible
34+
version such as \fB1.5.1\fR prior to yanking \fB1.5.0\fR so that \fBbar\fR and all projects
35+
that depend on \fBbar\fR will continue to work.
36+
.sp
37+
As another example, consider a crate \fBbar\fR with published versions \fB1.5.0\fR,
38+
\fB1.5.1\fR, \fB1.5.2\fR, \fB2.0.0\fR and \fB3.0.0\fR\&. The following table identifies the
39+
versions cargo could use in the absence of a lockfile for different SemVer
40+
requirements, following a given release being yanked:
41+
42+
.TS
43+
allbox tab(:);
44+
lt lt lt lt.
45+
T{
46+
Yanked Version / SemVer requirement
47+
T}:T{
48+
\fBbar = "1.5.0"\fR
49+
T}:T{
50+
\fBbar = "=1.5.0"\fR
51+
T}:T{
52+
\fBbar = "2.0.0"\fR
53+
T}
54+
T{
55+
\fB1.5.0\fR
56+
T}:T{
57+
Use either \fB1.5.1\fR or \fB1.5.2\fR
58+
T}:T{
59+
\fBReturn Error\fR
60+
T}:T{
61+
Use \fB2.0.0\fR
62+
T}
63+
T{
64+
\fB1.5.1\fR
65+
T}:T{
66+
Use either \fB1.5.0\fR or \fB1.5.2\fR
67+
T}:T{
68+
Use \fB1.5.0\fR
69+
T}:T{
70+
Use \fB2.0.0\fR
71+
T}
72+
T{
73+
\fB2.0.0\fR
74+
T}:T{
75+
Use either \fB1.5.0\fR, \fB1.5.1\fR or \fB0.22.2\fR
76+
T}:T{
77+
Use \fB1.5.0\fR
78+
T}:T{
79+
\fBReturn Error\fR
80+
T}
81+
.TE
82+
.sp
83+
.SS "When to yank"
84+
Crates should only be yanked in exceptional circumstances, for example, an
85+
accidental publish, an unintentional SemVer breakages, or a significantly
86+
broken and unusable crate. In the case of security vulnerabilities, \fIRustSec\fR <https://rustsec.org/>
87+
is typically a less disruptive mechanism to inform users and encourage them
88+
to upgrade, and avoids the possibility of significant downstream disruption
89+
irrespective of susceptibility to the vulnerability in question.
90+
.sp
91+
A common workflow is to yank a crate having already published a semver
92+
compatible version, to reduce the probability of preventing dependent
93+
crates from compiling.
94+
.sp
95+
To address copyright, licensing, or personal data issues with your published
96+
crate, contact the maintainers of the registry you used. For crates.io, refer
97+
to their \fIpolicies\fR <https://crates.io/policies> and contact them at <[email protected]>\&.
98+
.sp
99+
If your credentials have been leaked, the recommended process is to revoke them
100+
immediately. Once a crate is published, it\[cq]s impossible to know if those leaked
101+
credentials have been copied, so taking swift action is crucial.
26102
.SH "OPTIONS"
27103
.SS "Yank Options"
28104
.sp

0 commit comments

Comments
 (0)