linera-io/linera-protocol · error · anyhow::Error
Project name {name} should not contain path-separators
Error message
Project name {name} should not contain path-separators What it means
Project::create_new scaffolds a new Linera application project into a directory named after the project; a path separator in the name would escape the intended directory, so any name containing '/' (or '\' on Windows, via std::path::is_separator) is rejected before anything is created.
Source
Thrown at linera-service/src/project.rs:29
use cargo_toml::Manifest;
use convert_case::{Case, Casing};
use current_platform::CURRENT_PLATFORM;
use fs_err::File;
use tracing::debug;
/// A Linera application project on disk, rooted at a given directory.
pub struct Project {
root: PathBuf,
}
impl Project {
/// Creates a new application project from the template, scaffolding its files.
pub fn create_new(
name: &str,
linera_root: Option<&Path>,
dir: Option<PathBuf>,
) -> Result<Self> {
ensure!(
!name.contains(std::path::is_separator),
"Project name {name} should not contain path-separators",
);
let root = match dir {
Some(dir) => dir,
None => {
let root = PathBuf::from(name);
ensure!(
!root.exists(),
"Directory {} already exists",
root.display(),
);
root
}
};
ensure!(
root.extension().is_none(),
"Project name {name} should not have a file extension",View on GitHub (pinned to 6c226ddcb3)
Solutions
- Use a plain name: `linera project new my-app`
- To scaffold into a specific location, pass the directory separately (create_new's dir parameter) rather than embedding a path in the name
- Replace separators with dashes
Example fix
# before $ linera project new my/dapp error: Project name my/dapp should not contain path-separators # after $ linera project new my-dapp
Defensive patterns
Strategy: validation
Validate before calling
if name.contains(std::path::is_separator) {
anyhow::bail!("project name must not contain path separators: {name}");
} Type guard
fn is_valid_project_name(name: &str) -> bool {
!name.is_empty()
&& !name.contains(std::path::is_separator)
&& std::path::Path::new(name).extension().is_none()
} Prevention
- Pass bare names, never paths, to project creation
- Sanitize user-supplied names in tooling that wraps the CLI
When it happens
Trigger: `linera project new` with a name like `my/app`, `../evil`, or any other string containing a path separator.
Common situations: Passing a relative path instead of a bare name; copy-pasting 'org/app' style package names; Windows users typing backslashes.
Related errors
- Project name {name} should not have a file extension
- Directory {} already exists
- No Cargo.toml found at {}. The path must point to a Rust pro
- failed to initialize git repository at {}
- Only allowed options are grpc and grpcs
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/382ceb4adf90654d.
Report an issue: GitHub.