Skip to content

/errors/cargo/believes-its-in-a-workspace

Cargo: error: current package believes it's in a workspace when it's not

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · cargo 1.98.1 (797e8a9bc 2026-08-05)updated
tool
Cargo
exit code
101
versions
Rust 1.x
os
any

error: current package believes it's in a workspace when it's not means Cargo found a Cargo.toml with a [workspace] section in a parent folder, but the current package is not one of its members. Cargo then does not know which workspace (and which Cargo.lock and target/) to use. Cargo prints both manifest paths and suggests the fix: add the package to workspace.members, add it to workspace.exclude, or give the package its own empty [workspace] table.

Reproduce it

bash
cat > Cargo.toml <<'EOF'
[workspace]
members = []
EOF
mkdir -p tool/src
cat > tool/Cargo.toml <<'EOF'
[package]
name = "tool"
version = "0.1.0"
edition = "2021"
EOF
echo 'fn main() { println!("hi"); }' > tool/src/main.rs
cd tool
cargo build

Output · exit 101

error: current package believes it's in a workspace when it's not:
current:   /tmp/work/tool/Cargo.toml
workspace: /tmp/work/Cargo.toml

this may be fixable by adding `tool` to the `workspace.members` array of the manifest located at: /tmp/work/Cargo.toml
Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.

Fix

Add the package to the workspace members (or use a glob such as "crates/*"):

bash
cat > Cargo.toml <<'EOF'
[workspace]
members = ["tool"]
resolver = "2"
EOF
mkdir -p tool/src
cat > tool/Cargo.toml <<'EOF'
[package]
name = "tool"
version = "0.1.0"
edition = "2021"
EOF
echo 'fn main() { println!("hi"); }' > tool/src/main.rs
cd tool
cargo run -q

Output

hi
GoalChange
The crate is part of the workspacemembers = ["tool"] in the parent [workspace]
The crate is unrelated to the parent projectexclude = ["tool"] in the parent [workspace]
Keep the parent unchangedAdd an empty [workspace] table to tool/Cargo.toml

Inside a workspace, all members share one Cargo.lock and one target/ folder at the workspace root.

Sources