linera-io/linera-protocol · error · anyhow::Error
Project name {name} should not have a file extension
Error message
Project name {name} should not have a file extension What it means
create_new rejects project names that parse as having a file extension (Path::extension() returns Some), because the name becomes a directory and a dotted name like `my.app` would look like a file path. Any final dot-separated component triggers the rejection.
Source
Thrown at linera-service/src/project.rs:45
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",
);
debug!("Creating directory at {}", root.display());
fs_err::create_dir_all(&root)?;
debug!("Creating the source directory");
let source_directory = Self::create_source_directory(&root)?;
debug!("Creating the tests directory");
let test_directory = Self::create_test_directory(&root)?;
debug!("Initializing git repository");
Self::initialize_git_repository(&root)?;
debug!("Writing Cargo.toml");
Self::create_cargo_toml(&root, name, linera_root)?;
View on GitHub (pinned to 6c226ddcb3)
Solutions
- Strip the dotted suffix: use `my-app` instead of `my.app` or `my-dapp-1.0`
- Replace dots with dashes in the name
Example fix
# before $ linera project new my-dapp-1.0 error: Project name my-dapp-1.0 should not have a file extension # after $ linera project new my-dapp-1-0
Defensive patterns
Strategy: validation
Validate before calling
if std::path::Path::new(name).extension().is_some() {
anyhow::bail!("project name must not contain a file extension: {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
- Use dashes instead of dots in project names
- Avoid embedding version numbers in scaffold names
When it happens
Trigger: `linera project new my.app`, `my-dapp-0.1`, or any name whose last '.'-separated component is treated as an extension.
Common situations: Appending version numbers ('app-1.0') or dotted codenames to project names when scaffolding.
Related errors
- Project name {name} should not contain path-separators
- 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/3ba6ac1f6493c122.
Report an issue: GitHub.