slint-ui/slint · error
Not a workspace, can not extract version info.
Error message
Not a workspace, can not extract version info.
What it means
CargoToml::workspace_version was called on a Cargo.toml that is not a workspace root (it has no [workspace] table), so no workspace.package.version can be extracted. The xtask license/version consistency check uses this to resolve inherited fields in member crates; calling it on a member manifest is an unsupported operation for that file kind.
Solutions
- Call workspace_version only on manifests where is_workspace() is true; route member manifests through the package() path instead.
- Run the xtask license/version check from the workspace root so the root Cargo.toml is used for version extraction.
- If this fires unexpectedly, check the manifest for a [workspace] table; add one or fix the file-walk glob that picked the wrong manifest.
- Refactor to a single resolver that checks is_workspace() once and returns the version from either workspace.package.version or package.version.
Example fix
// before
let version = cargo_toml.workspace_version()?;
// after
let version = if cargo_toml.is_workspace() {
cargo_toml.workspace_version()?.to_owned()
} else {
cargo_toml.package()?.get("version").and_then(|v| v.as_str()).unwrap_or_default().to_owned()
}; Defensive patterns
Strategy: validation
Validate before calling
let version = if cargo_toml.is_workspace() {
cargo_toml.workspace_version()?.to_owned()
} else {
// fall back to the member's own package version or look up the root manifest
cargo_toml.package()?.get("version")
.and_then(|v| v.as_str()).unwrap_or("").to_owned()
}; Type guard
fn is_workspace_root(doc: &toml_edit::DocumentMut) -> bool {
doc.as_table().get("workspace").is_some()
} Try / catch
match cargo_toml.workspace_version() {
Ok(v) => use_version(v),
Err(e) if e.to_string().contains("Not a workspace") => {
// manifest is a member: resolve the version from the workspace root instead
use_version(&resolve_root_version()?)
}
Err(e) => return Err(e),
} Prevention
- Gate workspace_version calls behind is_workspace().
- Run xtask checks from the repository/workspace root.
- Resolve inherited fields through one helper that handles both manifest kinds.
- Review any change that promotes a member manifest to a workspace root.
When it happens
Trigger: The check iterates manifests and passes a member crate's Cargo.toml (or any manifest without a [workspace] section) into workspace_version, which requires a workspace root with workspace.package.version.
Common situations: Running the xtask check against a single member crate directory instead of the repo root; a refactoring turned a former workspace root into a member; a vendored/example Cargo.toml without [workspace] is included in the manifest walk.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Invalid Cargo.toml -- cannot find workspace package section…
- Incorrect .workspace found: expected true, found false
- Invalid Cargo.toml -- cannot find package section
- Using workspace .workspace = true in workspace
- cargo failed
AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16).
Data as JSON: /api/errors/2ac0f7ead29010a6.
Report an issue: GitHub.
Appendix: source
Thrown at xtask/src/license_headers_check.rs:791
struct CargoToml {
path: std::path::PathBuf,
doc: toml_edit::DocumentMut,
edited: bool,
}
impl CargoToml {
fn new(path: &Path) -> Result<Self> {
let source = &std::fs::read_to_string(path).context("Error reading file")?;
Ok(Self { doc: source.parse()?, edited: false, path: path.to_path_buf() })
}
fn is_workspace(&self) -> bool {
self.doc.as_table().get("workspace").is_some()
}
fn workspace_version(&self) -> Result<&str> {
if !self.is_workspace() {
Err(anyhow!("Not a workspace, can not extract version info."))
} else {
Ok(self
.doc
.as_table()
.get("workspace")
.unwrap()
.get("package")
.unwrap()
.get("version")
.unwrap()
.as_str()
.unwrap())
}
}
fn package(&self) -> Result<&toml_edit::Table> {
if self.is_workspace() {
self.docView on GitHub (pinned to 3a7e700487)