bump releases Rust crates the same way as npm packages. It reads and edits Cargo.toml and Cargo.lock itself, so it does not need cargo.
Find the crates
Without packages in the config, bump reads [workspace] in the root Cargo.toml:
- Each folder that
membersmatches is a member.excluderemoves folders. - If the root
Cargo.tomlalso has a[package], the root crate is a member. - Each path dependency of a member is a member too, when it is inside the root and
excludedoes not remove it. Cargo has the same rule.
Without [workspace], bump looks only for a Cargo.toml in the root folder.
With packages in the config, bump looks for a Cargo.toml in each matched folder. See packages.
A virtual manifest, with [workspace] and no [package], is not a crate. bump skips it with no warning.
Versions
A crate's version is [package] version. A crate with no version has no version for bump: it is not released, but it still gets range edits.
A crate can inherit the version of its Cargo workspace:
[package]
name = "acme-core"
version.workspace = trueThe version then comes from [workspace.package] version of the Cargo workspace root. bump finds that root like Cargo does:
- the folder that
package.workspacenames, if it is set; - else the crate's own folder, if its
Cargo.tomlhas[workspace]; - else the nearest parent folder, up to the git top level, whose
Cargo.tomlhas[workspace].
A repository can hold several Cargo workspaces. bump handles each one alone.
Shared versions
Crates that inherit the version share one value. bump writes it in one place, so those crates must release together, as one unit.
In lockstep mode, all crates are one unit already. But every crate must have the same version, also the crates with their own version. This workspace has acme-core and acme-cli at the shared 0.3.0, and acme-macros at its own 1.0.0:
$ bump patch --dryrun
FAIL All packages must share one version in lockstep mode:
│ acme-cli 0.3.0
│ acme-core 0.3.0
│ acme-macros 1.0.0In independent mode, bump needs a group for the crates that share the version:
$ bump patch --dryrun
FAIL Crates "acme-cli", "acme-core" share [workspace.package] version; name them in "groups", e.g. "groups": { "<name>": ["acme-cli"] }bump finds the unit of the crates that inherit the version of one workspace:
- If only one crate inherits the version, it needs no group.
- Else, if a group lists any of them, all of them join that group. You need to list only one.
- Else, if the workspace root
Cargo.tomlhas a[package]that inherits the version, they form a group with the name of that root crate. - Else, bump stops with the error above.
Example
The workspace root:
[workspace]
members = ["crates/*"]
resolver = "2"
[workspace.package]
version = "0.3.0"
edition = "2024"
[workspace.dependencies]
acme-core = { path = "crates/core", version = "0.3.0" }
acme-macros = { path = "crates/macros", version = "1.0" }acme-core and acme-cli inherit the version. acme-core depends on acme-macros, and acme-cli depends on acme-core, both through { workspace = true }. One group is enough:
{
"independent": true,
"groups": {
"acme": ["acme-core"]
}
}acme-cli joins the acme group. The tags are acme@0.3.0 and acme-macros@1.0.0. After a change to acme-macros:
$ bump minor
BUMP acme-macros 1.0.0 → 1.1.0 (changed)
BUMP acme 0.3.0 → 0.3.1 (dependent)
acme-core, acme-cli
EDIT Cargo.toml workspace.dependencies["acme-core"] 0.3.0 → 0.3.1
EDIT Cargo.toml workspace.dependencies["acme-macros"] 1.0 → 1.1
DONE Committed 8dafdd4 release: acme-macros@1.1.0, acme@0.3.1
Tagged acme-macros@1.1.0, acme@0.3.1The release commit changes three files: [workspace.package] version and [workspace.dependencies] in Cargo.toml, the version in crates/macros/Cargo.toml, and Cargo.lock.
Dependencies
An internal dependency is an entry whose crate is in the repository. These tables count:
| Table | Kind |
|---|---|
[dependencies], [build-dependencies] |
runtime |
[target.<cfg>.dependencies], [target.<cfg>.build-dependencies] |
runtime |
[dev-dependencies], [target.<cfg>.dev-dependencies] |
dev |
A runtime dependency makes the crate a dependent. A dev dependency gets range edits only.
bump edits the range of each form:
acme-core = "0.3.0": the string.acme-core = { path = "../core", version = "0.3.0" }, or a[dependencies.acme-core]table: theversionkey.acme-core = { workspace = true }: the entry in[workspace.dependencies]of the Cargo workspace root, one time for all crates that use it. It is a runtime dependency if any crate uses it at runtime.{ path = "../core" }with noversion: nothing to edit. It is still an internal dependency.core = { package = "acme-core", … }: the dependency isacme-core, notcore.
The new range keeps the prefix and the precision of the old one, as in 1.0 to 1.1. See Range rewrite.
An edit in [workspace.dependencies] belongs to no crate. Its EDIT line shows the file path, and its package in the JSON result is null.
Cargo.lock
bump edits each Cargo.lock that git tracks. See Lockfiles for the rules. From the example above:
[[package]]
name = "acme-cli"
version = "0.3.1"
dependencies = [
"acme-core",
]Publish
The JSON result gives publish for each released crate. It is false when the crate has publish = false or publish = []. With publish.workspace = true, bump reads [workspace.package] publish with the same rule. Here acme-cli has publish = false:
{
"name": "acme-cli",
"ecosystem": "cargo",
"dir": "crates/cli",
"publish": false
}bump releases a crate with publish = false like any other crate. Use the field to decide which crates to give to cargo publish.
Changes in the workspace root
A file belongs to the deepest package folder that holds it. A virtual root Cargo.toml is no package, so the root folder belongs to no crate. A change to [workspace.package] or [workspace.dependencies], such as a new edition, releases nothing by itself. A root crate, as in rule 3 above, owns every file that no deeper crate owns. See Owners.
Mixed npm and Cargo
One repository can hold npm packages and crates. One folder can hold both, such as a Node addon written in Rust:
{
"name": "@acme/fast",
"version": "1.2.0",
"main": "index.js"
}[package]
name = "acme-fast"
version = "1.2.0"
edition = "2024"
[lib]
crate-type = ["cdylib"]With no config, bump finds both in the root folder. In lockstep mode they are one unit:
$ bump minor
BUMP 1.2.0 → 1.3.0 (changed)
@acme/fast, acme-fast
DONE Committed 2b490a0 v1.3.0
Tagged v1.3.0The release commit changes package.json, Cargo.toml, and Cargo.lock.
In independent mode, put the two in a group, so that they release together.
- Package names must be unique across both ecosystems. Two packages with the same name are an error.
- A dependency is internal only within its own ecosystem. An npm package cannot depend on a crate, so they make no dependents across ecosystems.