linera-io/linera-protocol · error · anyhow::Error
No Cargo.toml found at {}. The path must point to a Rust pro
Error message
No Cargo.toml found at {}. The path must point to a Rust project directory. What it means
Project::from_existing_project treats the given path as a Rust project root and requires a Cargo.toml there. Without a manifest the path is not a Cargo project, so building the application's WASM contract and service is impossible and the call fails.
Source
Thrown at linera-service/src/project.rs:94
debug!("Writing service.rs");
Self::create_service_file(&source_directory, name)?;
debug!("Writing single_chain.rs");
Self::create_test_file(&test_directory, name)?;
Ok(Self { root })
}
/// Opens an existing application project at the given root directory.
pub fn from_existing_project(root: &Path) -> Result<Self> {
let root = root.canonicalize().with_context(|| {
format!(
"Could not find project at {}. \
Make sure the specified directory exists.",
root.display()
)
})?;
ensure!(
root.join("Cargo.toml").exists(),
"No Cargo.toml found at {}. \
The path must point to a Rust project directory.",
root.display()
);
Ok(Self { root })
}
/// Runs the unit and integration tests of an application.
pub fn test(&self) -> Result<()> {
let tests = Command::new("cargo")
.arg("test")
.args(["--target", CURRENT_PLATFORM])
.current_dir(&self.root)
.spawn()?
.wait()?;
ensure!(tests.success(), "tests failed");
Ok(())View on GitHub (pinned to 6c226ddcb3)
Solutions
- Pass the directory that actually contains Cargo.toml — usually your application's crate root
- Verify with `ls <path>/Cargo.toml` before running the command
- If the project does not exist yet, create it first with `linera project new`
Example fix
# before $ linera project publish ./my-dapp/src error: No Cargo.toml found at my-dapp/src ... # after $ linera project publish ./my-dapp
Defensive patterns
Strategy: validation
Validate before calling
let manifest = path.join("Cargo.toml");
if !manifest.exists() {
anyhow::bail!("not a Rust project (no Cargo.toml at {})", path.display());
} Type guard
fn is_rust_project(path: &std::path::Path) -> bool {
path.join("Cargo.toml").exists()
} Prevention
- Always pass the crate root directory, not src/ or build output
- Verify with ls <path>/Cargo.toml before publish commands
When it happens
Trigger: `linera project publish <path>` (or any from_existing_project caller) where <path>/Cargo.toml does not exist: wrong directory, a typo in the path, or a non-Rust project.
Common situations: Running publish from the wrong cwd or pointing at the source subdir (src/) or build output instead of the crate root; the project was never scaffolded with `linera project new`.
Related errors
- Project name {name} should not contain path-separators
- Project name {name} should not have a file extension
- tests failed
- build failed
- Only allowed options are grpc and grpcs
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/d30adc4deaff6700.
Report an issue: GitHub.