diff --git a/crates/pixi_manifest/src/toml/workspace.rs b/crates/pixi_manifest/src/toml/workspace.rs index 260331b823..ae0e9a97ff 100644 --- a/crates/pixi_manifest/src/toml/workspace.rs +++ b/crates/pixi_manifest/src/toml/workspace.rs @@ -107,13 +107,21 @@ impl TomlWorkspace { } = self.preview.into_preview(); let warnings = preview_warnings; + let missing_field_name_error = Error { + kind: ErrorKind::MissingField("name"), + span: self.span, + line_info: None, + }; Ok(WithWarnings::from(Workspace { - name: self.name.or(external.name).ok_or(Error { - kind: ErrorKind::MissingField("name"), - span: self.span, - line_info: None, - })?, + name: self.name.or(external.name).unwrap_or( + root_directory + .ok_or(missing_field_name_error.clone())? + .file_name() + .ok_or(missing_field_name_error)? + .to_string_lossy() + .to_string(), + ), version: self.version.or(external.version), description: self.description.or(external.description), authors: self.authors.or(external.authors), diff --git a/docs/reference/pixi_manifest.md b/docs/reference/pixi_manifest.md index 481ae0ff5a..3250c508db 100644 --- a/docs/reference/pixi_manifest.md +++ b/docs/reference/pixi_manifest.md @@ -36,14 +36,6 @@ The minimally required information in the `project` table is: --8<-- "docs/source_files/pixi_tomls/simple_pixi.toml:project" ``` -### `name` - -The name of the project. - -```toml ---8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_name" -``` - ### `channels` This is a list that defines the channels used to fetch the packages from. @@ -82,6 +74,14 @@ The available platforms are listed here: [link](https://docs.rs/rattler_conda_ty Fallback: If `osx-arm64` can't resolve, use `osx-64`. Running `osx-64` on Apple Silicon uses [Rosetta](https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment) for Intel binaries. +### `name` (optional) + +The name of the project. If not defined, the root directory name will be assumed as the project name. + +```toml +--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_name" +``` + ### `version` (optional) The version of the project. diff --git a/docs/source_files/pixi_tomls/simple_pixi.toml b/docs/source_files/pixi_tomls/simple_pixi.toml index d7d041eb82..2b7f0c9cfa 100644 --- a/docs/source_files/pixi_tomls/simple_pixi.toml +++ b/docs/source_files/pixi_tomls/simple_pixi.toml @@ -2,6 +2,5 @@ # --8<-- [start:project] [workspace] channels = ["conda-forge"] -name = "project-name" platforms = ["linux-64"] # --8<-- [end:project]