python-poetry/poetry · error · RuntimeError
The dependency name for {dependency.name} does not match the
Error message
The dependency name for {dependency.name} does not match the actual package's name: {package.name} What it means
Raised by Provider.validate_package_for_dependency() when a resolved Package's name differs from the Dependency's name that pulled it in. Poetry requires the canonical names to match so the resolver's bookkeeping stays consistent; a mismatch usually indicates the dependency was pointed at a distribution whose real package name differs (e.g. a renamed project).
Source
Thrown at src/poetry/puzzle/provider.py:277
self._env = None
self._package_python_constraint = original_python_constraint
@contextmanager
def use_latest_for(self, names: Collection[NormalizedName]) -> Iterator[Provider]:
self._use_latest = names
try:
yield self
finally:
self._use_latest = []
@staticmethod
def validate_package_for_dependency(
dependency: Dependency, package: Package
) -> None:
if dependency.name != package.name:
# For now, the dependency's name must match the actual package's name
raise RuntimeError(
f"The dependency name for {dependency.name} does not match the actual"
f" package's name: {package.name}"
)
def search_for_direct_origin_dependency(self, dependency: Dependency) -> Package:
package = self._deferred_cache.get(dependency)
if package is not None:
pass
elif dependency.is_vcs():
dependency = cast("VCSDependency", dependency)
package = self._search_for_vcs(dependency)
elif dependency.is_file():
dependency = cast("FileDependency", dependency)
package = self._search_for_file(dependency)
elif dependency.is_directory():View on GitHub (pinned to 92b74dcfe3)
Solutions
- Update the dependency declaration to use the package's actual canonical name.
- If the project was renamed, point at the new name and version.
- For url/vcs/file deps, verify the upstream's pyproject.toml/setup.py [project].name matches what you declared.
- Run `poetry show <dep>` or inspect the fetched archive metadata to confirm the real name.
Example fix
// before: dependency name mismatch
[tool.poetry.dependencies]
foo = { git = "https://github.com/org/foo-lib.git" }
# but foo-lib's pyproject.toml name = "foo-lib"
// after
[tool.poetry.dependencies]
foo-lib = { git = "https://github.com/org/foo-lib.git" } Defensive patterns
Strategy: validation
Validate before calling
from poetry.core.utils.patterns import canonicalize_name
def names_match(dependency_name: str, package_name: str) -> bool:
return canonicalize_name(dependency_name) == canonicalize_name(package_name) Try / catch
from poetry.puzzle.provider import Provider
try:
Provider.validate_package_for_dependency(dep, pkg)
except RuntimeError:
# names diverge; realign the declaration to pkg.name
... Prevention
- Keep dependency names in sync with upstream package renames.
- For url/vcs/file deps, verify the upstream [project].name before declaring.
- Run `poetry lock` after renaming to catch mismatches early.
- Prefer canonical (PEP 503-normalised) names in declarations.
When it happens
Trigger: A dependency declaration names one package but the source it resolves to (file/url/vcs/directory) yields a package with a different canonical name. validate_package_for_dependency() is called after a direct-origin or source package is fetched.
Common situations: A dependency on 'foo' that actually installs a project renamed to 'foo-lib'; a git/url dep where the repo/package was renamed but pyproject.toml still references the old name; a fork published under a different name; a wheel whose metadata name differs from its filename.
Related errors
- {dependency}: unknown direct dependency type {dependency.sou
- Incompatible constraints in requirements of {package}: {cons
- Could not find a matching version of package {name}
- Unsupported VCS dependency {vcs}
- Invalid dependency specification: {requirement}
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/8afee99a75fdc123.json.
Report an issue: GitHub.