Description
Commitizen crashes when using version_provider = "cargo" on a Cargo workspace virtual manifest (root Cargo.toml contains [workspace] and [workspace.package] but no [package]). Our workspace members inherit version via version.workspace = true. Running cz bump fails inside commitizen/providers/cargo_provider.py while trying to update Cargo.lock.
This prevents using Commitizen’s cargo provider for monorepo-style Rust workspaces where the version is centralized in [workspace.package].version.
Steps to reproduce
-
Create a Cargo workspace that uses a virtual manifest at the root (no [package]), with a centralized version:
# ./Cargo.toml (workspace root)
[workspace]
members = ["crates/a"]
[workspace.package]
version = "0.1.0"
edition = "2024"
-
Create a member crate that inherits the version via version.workspace = true:
# ./crates/a/Cargo.toml
[package]
name = "a"
version.workspace = true
edition.workspace = true
-
Configure Commitizen to use the cargo provider:
# ./cz.toml
[tool.commitizen]
name = "cz_conventional_commits"
version_scheme = "semver"
version_provider = "cargo"
tag_format = "v$version"
update_changelog_on_bump = true
-
Run:
-
Observe the crash inside commitizen/providers/cargo_provider.py (during manifest parsing / Cargo.lock update).
Current behavior
cz bump crashes with exceptions from cargo_provider.py:
tomlkit.exceptions.NonExistentKey: 'Key "package" does not exist.' (root manifest has no [package])
- then
TypeError: string indices must be integers, not 'str' (when accessing package_content["version"]["workspace"] for members)
The command terminates without completing the bump/tag operation.
Desired behavior
cz bump should support Cargo workspaces with a virtual manifest (root Cargo.toml has [workspace] / [workspace.package] but no [package]) and members using version.workspace = true.
Concretely:
- Read and bump the canonical version from
[workspace.package].version.
- Do not assume
[package] exists in the workspace root manifest.
- When scanning/updating member manifests, correctly handle
version.workspace = true (a nested table / boolean) without type errors.
Screenshots
No response
Environment
(computation) juncheng@localhost:~/projects/computation$ cz version --report
Commitizen Version: 4.10.1
Python Version: 3.11.12 (main, Apr 9 2025, 04:04:00) [Clang 20.1.0 ]
Operating System: Linux