Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify Implications of Cargo Yank #11071

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 33 additions & 3 deletions src/doc/man/cargo-yank.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,39 @@ The yank command removes a previously published crate's version from the
server's index. This command does not delete any data, and the crate will
still be available for download via the registry's download link.

Note that existing crates locked to a yanked version will still be able to
download the yanked version to use it. Cargo will, however, not allow any new
crates to be locked to any yanked version.
Crates should only be yanked in exceptional circumstances, for example, license/copyright issues, accidental
inclusion of [PII](https://en.wikipedia.org/wiki/Personal_data), credentials, etc... In the case of security
vulnerabilities, [RustSec](https://rustsec.org/) is typically a less disruptive mechanism to inform users
and encourage them to upgrade, and avoids the possibility of significant downstream disruption irrespective
of susceptibility to the vulnerability in question.
Comment on lines +18 to +22
Copy link
Member

@weihanglo weihanglo Sep 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you feel putting them in the end of this DESCRIPTION section, under a subsection heading like ### When to yank or something better?

Just trying to make it look less lengthy and more organized. The content itself is really well-written! Thank you!


Cargo will not use a yanked version for any new project or checkout without a
pre-existing lockfile, and will generate an error if there are no longer
any compatible versions for your crate.

For example, the `foo` crate published version `0.22.0` and another crate `bar`
declared a dependency on version `foo = 0.22`. Now `foo` releases a new, but
not semver compatible, version `0.23.0`, and finds a critical issue with `0.22.0`.
If `0.22.0` is yanked, no new project or checkout without an existing lockfile will be
able to use crate `bar` as it relies on `0.22`.

In this case, the maintainers of `foo` should first publish a semver compatible version
such as `0.22.1` prior to yanking `0.22.0` so that `bar` and all projects that depend
on `bar` will continue to work.
Comment on lines +34 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph concludes the example really well, thought it feels like somewhat a duplicate of line 49-50. A challenge in documentation is putting the right amount. Could we find a way to merge them and make it more concise? It is not a blocker on merging this PR though.


As another example, consider a crate `bar` with published versions `0.22.0`, `0.22.1`,
`0.22.2`, `0.23.0` and `0.24.0`. The following table identifies the versions
cargo could use in the absence of a lockfile for different SemVer requirements,
following a given release being yanked:

| Yanked Version / SemVer requirement | `bar = "0.22.0"` | `bar = "=0.22.0"` | `bar = "0.23.0"` |
|-------------------------------------|-------------------------------------------|-------------------|------------------|
| `0.22.0` | Use either `0.22.1` or `0.22.2` | **Return Error** | Use `0.23.0` |
| `0.22.1` | Use either `0.22.0` or `0.22.2` | Use `0.22.0` | Use `0.23.0` |
| `0.23.0` | Use either `0.22.0`, `0.21.0` or `0.22.2` | Use `0.22.0` | **Return Error** |

A common workflow is to yank a crate having already published a semver compatible version,
to reduce the probability of preventing dependent crates from compiling.

This command requires you to be authenticated with either the `--token` option
or using {{man "cargo-login" 1}}.
Expand Down
48 changes: 45 additions & 3 deletions src/doc/man/generated_txt/cargo-yank.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,51 @@ DESCRIPTION
server's index. This command does not delete any data, and the crate
will still be available for download via the registry's download link.

Note that existing crates locked to a yanked version will still be able
to download the yanked version to use it. Cargo will, however, not allow
any new crates to be locked to any yanked version.
Crates should only be yanked in exceptional circumstances, for example,
license/copyright issues, accidental inclusion of PII
<https://en.wikipedia.org/wiki/Personal_data>, credentials, etc... In
the case of security vulnerabilities, RustSec <https://rustsec.org/> is
typically a less disruptive mechanism to inform users and encourage them
to upgrade, and avoids the possibility of significant downstream
disruption irrespective of susceptibility to the vulnerability in
question.

Cargo will not use a yanked version for any new project or checkout
without a pre-existing lockfile, and will generate an error if there are
no longer any compatible versions for your crate.

For example, the foo crate published version 0.22.0 and another crate
bar declared a dependency on version foo = 0.22. Now foo releases a new,
but not semver compatible, version 0.23.0, and finds a critical issue
with 0.22.0. If 0.22.0 is yanked, no new project or checkout without an
existing lockfile will be able to use crate bar as it relies on 0.22.

In this case, the maintainers of foo should first publish a semver
compatible version such as 0.22.1 prior to yanking 0.22.0 so that bar
and all projects that depend on bar will continue to work.

As another example, consider a crate bar with published versions 0.22.0,
0.22.1, 0.22.2, 0.23.0 and 0.24.0. The following table identifies the
versions cargo could use in the absence of a lockfile for different
SemVer requirements, following a given release being yanked:

+-----------------------+-----------------------+-----------+----------+
| Yanked Version / | bar = "0.22.0" | bar = | bar = |
| SemVer requirement | | "=0.22.0" | "0.23.0" |
+-----------------------+-----------------------+-----------+----------+
| 0.22.0 | Use either 0.22.1 or | Return | Use |
| | 0.22.2 | Error | 0.23.0 |
+-----------------------+-----------------------+-----------+----------+
| 0.22.1 | Use either 0.22.0 or | Use | Use |
| | 0.22.2 | 0.22.0 | 0.23.0 |
+-----------------------+-----------------------+-----------+----------+
| 0.23.0 | Use either 0.22.0, | Use | Return |
| | 0.21.0 or 0.22.2 | 0.22.0 | Error |
+-----------------------+-----------------------+-----------+----------+

A common workflow is to yank a crate having already published a semver
compatible version, to reduce the probability of preventing dependent
crates from compiling.

This command requires you to be authenticated with either the --token
option or using cargo-login(1).
Expand Down
36 changes: 33 additions & 3 deletions src/doc/src/commands/cargo-yank.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,39 @@ The yank command removes a previously published crate's version from the
server's index. This command does not delete any data, and the crate will
still be available for download via the registry's download link.

Note that existing crates locked to a yanked version will still be able to
download the yanked version to use it. Cargo will, however, not allow any new
crates to be locked to any yanked version.
Crates should only be yanked in exceptional circumstances, for example, license/copyright issues, accidental
inclusion of [PII](https://en.wikipedia.org/wiki/Personal_data), credentials, etc... In the case of security
vulnerabilities, [RustSec](https://rustsec.org/) is typically a less disruptive mechanism to inform users
and encourage them to upgrade, and avoids the possibility of significant downstream disruption irrespective
of susceptibility to the vulnerability in question.

Cargo will not use a yanked version for any new project or checkout without a
pre-existing lockfile, and will generate an error if there are no longer
any compatible versions for your crate.

For example, the `foo` crate published version `0.22.0` and another crate `bar`
declared a dependency on version `foo = 0.22`. Now `foo` releases a new, but
not semver compatible, version `0.23.0`, and finds a critical issue with `0.22.0`.
If `0.22.0` is yanked, no new project or checkout without an existing lockfile will be
able to use crate `bar` as it relies on `0.22`.

In this case, the maintainers of `foo` should first publish a semver compatible version
such as `0.22.1` prior to yanking `0.22.0` so that `bar` and all projects that depend
on `bar` will continue to work.

As another example, consider a crate `bar` with published versions `0.22.0`, `0.22.1`,
`0.22.2`, `0.23.0` and `0.24.0`. The following table identifies the versions
cargo could use in the absence of a lockfile for different SemVer requirements,
following a given release being yanked:

| Yanked Version / SemVer requirement | `bar = "0.22.0"` | `bar = "=0.22.0"` | `bar = "0.23.0"` |
|-------------------------------------|-------------------------------------------|-------------------|------------------|
| `0.22.0` | Use either `0.22.1` or `0.22.2` | **Return Error** | Use `0.23.0` |
| `0.22.1` | Use either `0.22.0` or `0.22.2` | Use `0.22.0` | Use `0.23.0` |
| `0.23.0` | Use either `0.22.0`, `0.21.0` or `0.22.2` | Use `0.22.0` | **Return Error** |

A common workflow is to yank a crate having already published a semver compatible version,
to reduce the probability of preventing dependent crates from compiling.

This command requires you to be authenticated with either the `--token` option
or using [cargo-login(1)](cargo-login.html).
Expand Down
72 changes: 69 additions & 3 deletions src/etc/man/cargo-yank.1
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,75 @@ The yank command removes a previously published crate's version from the
server's index. This command does not delete any data, and the crate will
still be available for download via the registry's download link.
.sp
Note that existing crates locked to a yanked version will still be able to
download the yanked version to use it. Cargo will, however, not allow any new
crates to be locked to any yanked version.
Crates should only be yanked in exceptional circumstances, for example, license/copyright issues, accidental
inclusion of \fIPII\fR <https://en.wikipedia.org/wiki/Personal_data>, credentials, etc... In the case of security
vulnerabilities, \fIRustSec\fR <https://rustsec.org/> is typically a less disruptive mechanism to inform users
and encourage them to upgrade, and avoids the possibility of significant downstream disruption irrespective
of susceptibility to the vulnerability in question.
.sp
Cargo will not use a yanked version for any new project or checkout without a
pre\-existing lockfile, and will generate an error if there are no longer
any compatible versions for your crate.
.sp
For example, the \fBfoo\fR crate published version \fB0.22.0\fR and another crate \fBbar\fR
declared a dependency on version \fBfoo = 0.22\fR\&. Now \fBfoo\fR releases a new, but
not semver compatible, version \fB0.23.0\fR, and finds a critical issue with \fB0.22.0\fR\&.
If \fB0.22.0\fR is yanked, no new project or checkout without an existing lockfile will be
able to use crate \fBbar\fR as it relies on \fB0.22\fR\&.
.sp
In this case, the maintainers of \fBfoo\fR should first publish a semver compatible version
such as \fB0.22.1\fR prior to yanking \fB0.22.0\fR so that \fBbar\fR and all projects that depend
on \fBbar\fR will continue to work.
.sp
As another example, consider a crate \fBbar\fR with published versions \fB0.22.0\fR, \fB0.22.1\fR,
\fB0.22.2\fR, \fB0.23.0\fR and \fB0.24.0\fR\&. The following table identifies the versions
cargo could use in the absence of a lockfile for different SemVer requirements,
following a given release being yanked:

.TS
allbox tab(:);
lt lt lt lt.
T{
Yanked Version / SemVer requirement
T}:T{
\fBbar = "0.22.0"\fR
T}:T{
\fBbar = "=0.22.0"\fR
T}:T{
\fBbar = "0.23.0"\fR
T}
T{
\fB0.22.0\fR
T}:T{
Use either \fB0.22.1\fR or \fB0.22.2\fR
T}:T{
\fBReturn Error\fR
T}:T{
Use \fB0.23.0\fR
T}
T{
\fB0.22.1\fR
T}:T{
Use either \fB0.22.0\fR or \fB0.22.2\fR
T}:T{
Use \fB0.22.0\fR
T}:T{
Use \fB0.23.0\fR
T}
T{
\fB0.23.0\fR
T}:T{
Use either \fB0.22.0\fR, \fB0.21.0\fR or \fB0.22.2\fR
T}:T{
Use \fB0.22.0\fR
T}:T{
\fBReturn Error\fR
T}
.TE
.sp
.sp
A common workflow is to yank a crate having already published a semver compatible version,
to reduce the probability of preventing dependent crates from compiling.
.sp
This command requires you to be authenticated with either the \fB\-\-token\fR option
or using \fBcargo\-login\fR(1).
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.