{"id":"3d208191b055501c","repo":"python-poetry/poetry","slug":"unable-to-create-package-with-no-name-for-root-di","errorCode":null,"errorMessage":"Unable to create package with no name for {root_dir}","messagePattern":"Unable to create package with no name for (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/poetry/inspection/info.py","lineNumber":133,"sourceCode":"        return cls(cache_version=cache_version, **data)\n\n    def to_package(\n        self, name: str | None = None, root_dir: Path | None = None\n    ) -> Package:\n        \"\"\"\n        Create a new `poetry.core.packages.package.Package` instance using metadata from\n        this instance.\n\n        :param name: Name to use for the package, if not specified name from this\n            instance is used.\n        :param extras: Extras to activate for this package.\n        :param root_dir:  Optional root directory to use for the package. If set,\n            dependency strings will be parsed relative to this directory.\n        \"\"\"\n        name = name or self.name\n\n        if not name:\n            raise RuntimeError(f\"Unable to create package with no name for {root_dir}\")\n\n        if not self.version:\n            # The version could not be determined, so we raise an error since it is\n            # mandatory.\n            raise RuntimeError(f\"Unable to retrieve the package version for {name}\")\n\n        package = Package(\n            name=name,\n            version=self.version,\n            source_type=self._source_type,\n            source_url=self._source_url,\n            source_reference=self._source_reference,\n            yanked=self.yanked,\n        )\n        if self.summary is not None:\n            package.description = self.summary\n        package.root_dir = root_dir\n        package.python_versions = self.requires_python or \"*\"","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/inspection/info.py#L115-L151","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before (broken package's setup.py)\nsetup(version=\"1.0\")\n\n# after\nsetup(name=\"some_pkg\", version=\"1.0\")","handlingStrategy":"try-catch","validationCode":"from poetry.inspection.info import PackageInfo\n\ninfo = PackageInfo.from_path(path)\nif not info.name:\n    raise ValueError(f'No package name in metadata at {path}; refusing to convert.')\npkg = info.to_package(root_dir=path)","typeGuard":"def has_name(info: PackageInfo) -> bool:\n    return bool(getattr(info, 'name', None))","tryCatchPattern":"try:\n    pkg = PackageInfo.from_path(path).to_package(root_dir=path)\nexcept RuntimeError as e:\n    if 'no name' in str(e):\n        # skip or report; cannot build a Package without a name\n        raise ValueError(f'Invalid package at {path}: missing name') from e\n    raise","preventionTips":["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."],"tags":["metadata","package-info","inspection","runtime-error"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}