python-poetry/poetry · error · RuntimeError
Unable to create package with no name for {root_dir}
Error message
Unable to create package with no name for {root_dir} What it means
Raised by PackageInfo.to_package() at src/poetry/inspection/info.py:132-133 when both the passed-in name and self.name are falsy. PackageInfo failed to read a name from the distribution's metadata, so a Package object cannot be constructed. This is a RuntimeError, not a controlled validation error.
Source
Thrown at src/poetry/inspection/info.py:133
return cls(cache_version=cache_version, **data)
def to_package(
self, name: str | None = None, root_dir: Path | None = None
) -> Package:
"""
Create a new `poetry.core.packages.package.Package` instance using metadata from
this instance.
:param name: Name to use for the package, if not specified name from this
instance is used.
:param extras: Extras to activate for this package.
:param root_dir: Optional root directory to use for the package. If set,
dependency strings will be parsed relative to this directory.
"""
name = name or self.name
if not name:
raise RuntimeError(f"Unable to create package with no name for {root_dir}")
if not self.version:
# The version could not be determined, so we raise an error since it is
# mandatory.
raise RuntimeError(f"Unable to retrieve the package version for {name}")
package = Package(
name=name,
version=self.version,
source_type=self._source_type,
source_url=self._source_url,
source_reference=self._source_reference,
yanked=self.yanked,
)
if self.summary is not None:
package.description = self.summary
package.root_dir = root_dir
package.python_versions = self.requires_python or "*"View on GitHub (pinned to 92b74dcfe3)
Solutions
- Open the offending package's METADATA/PKG-INFO and confirm a Name field exists.
- Fix the upstream package's build config (setup.py name= or [project] name in pyproject.toml).
- If the package is third-party and broken, pin to an earlier release that shipped valid metadata.
Example fix
# before (broken package's setup.py) setup(version="1.0") # after setup(name="some_pkg", version="1.0")
Defensive patterns
Strategy: try-catch
Validate before calling
from poetry.inspection.info import PackageInfo
info = PackageInfo.from_path(path)
if not info.name:
raise ValueError(f'No package name in metadata at {path}; refusing to convert.')
pkg = info.to_package(root_dir=path) Type guard
def has_name(info: PackageInfo) -> bool:
return bool(getattr(info, 'name', None)) Try / catch
try:
pkg = PackageInfo.from_path(path).to_package(root_dir=path)
except RuntimeError as e:
if 'no name' in str(e):
# skip or report; cannot build a Package without a name
raise ValueError(f'Invalid package at {path}: missing name') from e
raise Prevention
- Validate that the inspected artifact's METADATA has a Name field before calling to_package().
- In CI, fail package builds if name is missing rather than emitting a nameless artifact.
When it happens
Trigger: Inspecting an sdist/wheel/directory whose METADATA lacks a Name field, calling PackageInfo.from_path/.from_directory on it, then .to_package(). Common with hand-rolled setup.py that never calls setup(name=...) or with corrupt archives.
Common situations: Local directory dependency whose pyproject.toml has no [project] name, a wheel produced by a broken build, or a tarball missing PKG-INFO. Often surfaces during `poetry add ./some_pkg` or while resolving.
Related errors
- Unable to retrieve the package version for {name}
- Unknown metadata version: {dist.metadata_version}
- Unable to determine package info from path: {file_path}
- Invalid author string. Must be in the format: John Smith <jo
- The lock file does not have a metadata entry. Regenerate the
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/3d208191b055501c.json.
Report an issue: GitHub.