Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Cargo Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-cargo-knowledge-patch)
---
name: cargo-knowledge-patch
description: Cargo
version: "1.97.0"
license: MIT
metadata:
author: Nevaberry
---
# Cargo knowledge patch
Use this skill when changing Cargo manifests or configuration, upgrading build
automation, publishing workspace packages, or working with Cargo's nightly features.
Read the relevant topic reference for version-specific behavior and examples.
## Topic references
| Reference | Topics |
| --- | --- |
| [Upgrades and compatibility](references/upgrades-and-compatibility.md) | Extraction security, runtime libraries, manifest compatibility, automatic fixes, removed options, lockfile formats |
| [Configuration, networking, and cache](references/configuration-networking-and-cache.md) | Includes, precedence, relative paths, jobs, TLS, SSH, Git fetching, cache cleanup, terminal output |
| [Builds, targets, and artifacts](references/builds-targets-and-artifacts.md) | Host and custom targets, compiler flags, linking, build directories, cleanup, tests, documentation |
| [Packaging, publishing, and registries](references/packaging-publishing-and-registries.md) | Workspace publication, archive contents, VCS checks, credentials, registry protocols, installation |
| [Scripts, build scripts, and subcommands](references/scripts-build-scripts-and-subcommands.md) | Embedded manifests, script paths, build-script environment and metadata, completion, JSON output, Cargo library APIs |
| [Unstable analysis, lints, and build controls](references/unstable-analysis-and-lints.md) | Warning policy, Cargo lints, timing reports, build analysis, standard-library builds, compiler controls, SBOMs |
| [Workspaces, dependencies, and metadata](references/workspaces-dependencies-and-metadata.md) | Feature unification, dependency trees, patches, metadata, lockfile relocation, updates, cooldowns, vendoring |
## Upgrade and migration checks
On Unix-like systems, use a toolchain patched for both crate-extraction vulnerabilities
that can change permissions outside the extraction directory: CVE-2026-33055 and
CVE-2026-33056. Official Rust-distribution Cargo binaries require `libatomic` on
32-bit platforms; Cargo depends on OpenSSL 3.
Cargo warns about `edition` in target tables such as `[[bin]]`; set it under
`[package]`. New TOML 1.1 syntax in `Cargo.toml` requires Cargo 1.94 or later for
development; Cargo publishes a manifest older TOML parsers can still read.
`cargo fix` and `cargo clippy --fix` select the same default targets as `cargo check`.
Use `--all-targets` to fix all targets. `--edition` and `--edition-idioms` still
imply `--all-targets`.
```console
cargo fix --all-targets
cargo clippy --fix --all-targets
```
`cargo fix --allow-dirty` also permits staged changes. `cargo fix --edition`
migrates Rust 2024 workspace dependencies with a virtual root manifest.
`cargo fix` skips compiler suggestions requiring edits to more than one file.
With `cargo fix --broken-code`,
applied edits remain on disk even if the edited code fails to compile.
| Removed or deprecated interface | Supported guidance |
| --- | --- |
| `cargo publish --token` | Soft-deprecated; use a registry credential provider, such as `cargo:token` with `CARGO_REGISTRY_TOKEN` for crates.io. |
| Unstable `--out-dir` | Use `--artifact-dir` to copy final artifacts to a chosen directory. |
| `--timings=<FMT>` | Use `cargo build --timings` for current-build HTML or nightly `-Zbuild-analysis` logs for machine-readable data. |
| `--lockfile-path` | Use `resolver.lockfile-path` in Cargo configuration. |
| `cargo build --build-plan` | Removed from nightly Cargo. |
| `CARGO_RUSTC_CURRENT_DIR` | Removed; nightly `-Zroot-dir` configures the directory from which Cargo invokes rustc. |
Cargo warns about a relative `install.root` without a trailing slash. This form
currently resolves against the working directory and is slated to become
config-relative. `cargo init` rejects the home directory; use `cargo init my-project`
to initialize a project inside it.
## Configuration composition
Higher-priority configuration replaces the entire program path and argument list
for `registry.credential-provider`, `registries.*.credential-provider`,
`target.*.runner`, `host.runner`, `credential-alias.*`, and `doc.browser`.
For lists replaced as a unit, `--config` takes precedence over
environment variables, and nested lists also replace the lower-priority value.
The top-level `include` key works on stable Cargo; drop `-Zconfig-include`.
Use an array, such as `include = ["common.toml"]`; the single-string shorthand
was removed. An optional include can be absent without an error:
```toml
include = [{ path = "local.toml", optional = true }]
```
Include paths must be literal, end in `.toml`, and resolve relative to the file
containing `include`. Nested includes are recursive; later array entries override
earlier ones, and the including file's settings merge last. Cargo 1.97 resolves
relative `[env]` paths against the defining file when using includes and normalizes
`..` in included configuration paths.
Config-relative paths in `--config <path>` files resolve from two directories above
the file. Set `CARGO_HOME`, `RUSTUP_HOME`, and `RUSTUP_TOOLCHAIN` in the invoking
environment; Cargo rejects them in its `[env]` table.
## Build output and compiler behavior
`build.build-dir` works on stable Cargo; its internal layout may change between
releases. The template below puts each workspace's intermediate artifacts under
the shared Cargo cache:
```toml
[build]
build-dir = "{cargo-cache-home}/build/{workspace-path-hash}"
```
`{workspace-root}` expands to the workspace root; `{cargo-cache-home}` expands to
`CARGO_HOME`. The nightly `workspace-path-hash` behavior resolves symlinks before
hashing the workspace path. Cargo 1.100's default intermediate layout groups files
by build step and puts the build-configuration hash in the parent directory name;
scripts and tests reading the build directory may need path updates.
`cargo publish` treats `.crate` archives as intermediate artifacts, including when
`build.build-dir` is unset. Use `cargo package` to keep an archive as a final artifact.
Package verification uses the workspace's target directory.
`cargo clean --workspace` removes workspace members' build artifacts only.
Cargo 1.97 honors `build.target` during cleanup and validates explicit
`--target-dir` directories before removal; a missing explicit directory is a
successful no-op.
Trailing flags after `cargo rustc --` override conflicting `RUSTFLAGS`:
```console
RUSTFLAGS='-Copt-level=1' cargo rustc --lib -- -Copt-level=2
```
Use `host-tuple` in `--target` or `build.target` to select the local host triple.
Use nightly `-Zjson-target-spec` when passing a custom JSON target specification.
## Publishing and dependency management
Publish multiple workspace members together, including members that depend on each
other. Packages upload separately, so a server error can leave some members published.
```console
cargo publish --workspace
cargo publish -p foo -p bar
```
`cargo package` always includes `Cargo.lock`, including for libraries.
`cargo package --exclude-lockfile` skips verification of an existing lockfile.
`cargo package -p <member>` packages only selected members; name the package in the
current directory explicitly if it also belongs in the selection.
Setting `package.include` bypasses both repository and global Git ignore rules.
Packaging checks external readme and license files, symlinks pointing outside the
package root, and dirty workspace manifests. A build script creating even an empty directory in packaged
sources can fail verification.
Use `resolver.lockfile-path` on stable Cargo 1.97 and drop `-Zlockfile-path`.
The configured path must end in `Cargo.lock`. With nightly `-Zlockfile-path`,
`cargo install` honored the setting in Cargo 1.95, while Cargo 1.96 ignores it.
`cargo tree --depth workspace` shows only dependencies that are workspace members.
For nightly public-dependency trees, `--edges public` replaces `--depth public`
with `-Zpublic-dependency`. `cargo metadata` ignores `CARGO_BUILD_TARGET`.
Cargo 1.100 dependency cooldowns use `registry.global-min-publish-age` and apply
only to versions with `pubtime` in their index entries. `cargo install` bypasses
the cooldown for the installed crate and its dependencies. The dependency reference
contains the precise-update override and publication-cutoff guidance.
## Warning policy and build analysis
`build.warnings` works on stable Cargo 1.97 and defaults to `warn`.
Use `CARGO_BUILD_WARNINGS` for one invocation:
```console
CARGO_BUILD_WARNINGS=deny cargo check
```
The policy applies only to local packages. `allow` leaves denied diagnostics and
hard warnings visible. `deny` turns warning summaries into errors and stops on
denied warnings unless `--keep-going` is passed.
Cargo 1.100 enables `cargo::unused_dependencies` at `warn` by default on stable;
configure its level in `[lints.cargo]`. Warnings require a build covering every
target that could use the dependency. `cargo check --bin foo` can miss unused
`[dependencies]` in a multi-binary package; `[dev-dependencies]` are skipped entirely.
Nightly `-Zbuild-analysis` records timings and rebuild reasons across invocations,
with JSON Lines logs under `~/.cargo/log/` and a separate file per invocation.
Use `cargo report sessions`, `cargo report rebuilds`, and `cargo report timings`
with that feature to inspect saved sessions, rebuild reasons, and HTML timing reports.
## Scripts, build scripts, and cache maintenance
With nightly `-Zscript`, `cargo add` and `cargo remove` edit a script's embedded
manifest when passed the script as `--manifest-path`. Scripts ignore surrounding
workspaces and discover configuration from the script's directory.
On unreleased nightly, every embedded-manifest mutation writes an explicit edition.
Cargo sets `CARGO_CFG_FEATURE` for `build.rs` with the package's activated features.
`cargo::rerun-if-env-changed=VAR` also responds to changes through Cargo's `[env]`.
Nightly `multiple-build-scripts` exposes each script's output as `<script-name>_OUT_DIR`.
With nightly `-Zany-build-script-metadata`, build scripts can emit metadata even
when the package has no `links` key; it reaches dependents as `CARGO_DEP_<name>_<key>`.
Global cache cleanup removes network downloads after three months without access
and locally obtained files after one month. It is skipped with `--offline` or
`--frozen`. Only Cargo 1.78 and newer record the accesses used for cleanup; set
`cache.auto-clean-frequency = "never"` to retain entries used only by older versions.
The default cleanup-check cadence is `"1 day"`; `"always"` checks on every eligible
command, and durations such as `"1 week"` configure another cadence.