python-poetry/poetry · error · ValueError

There is no {repo_name} repository defined

Error message

There is no {repo_name} repository defined

What it means

Raises ValueError in ConfigCommand.handle() when the user reads a repository by name (matching the repo_regex with a group) but config.get(['repositories', repo_name]) returns None — meaning the repository was never defined. The check at line 198-200 fires during the read (no-value) path of the config command.

Source

Thrown at src/poetry/console/commands/config.py:200

                    key = f"installer.build-config-settings.{package_name}"

                    if value := config.get(key):
                        self.line(json.dumps(value))
                    else:
                        self.line(
                            f"No build config settings configured for <c1>{package_name}</>."
                        )
                return 0
            elif m := re.match(repo_regex, self.argument("key")):
                if not m.group(1):
                    value = {}
                    if config.get("repositories") is not None:
                        value = config.get("repositories")
                else:
                    repo_name = m.group(1)
                    repo = config.get(["repositories", repo_name])
                    if repo is None:
                        raise ValueError(f"There is no {repo_name} repository defined")

                    value = repo.get(sub_key, "") if (sub_key := m.group(2)) else repo

                self.line(str(value))
            else:
                if setting_key not in self.unique_config_values:
                    raise ValueError(f"There is no {setting_key} setting.")

                value = config.get(setting_key)

                if not isinstance(value, str):
                    value = json.dumps(value)

                self.line(value)

            return 0

        values: list[str] = self.argument("value")

View on GitHub (pinned to 92b74dcfe3)

Solutions

  1. List all repositories first: `poetry config repositories` to see defined names.
  2. Add the repository: `poetry config repositories.myrepo https://example.com/simple/`.

Example fix

# before (error)
poetry config repositories.myrepo
# after (add it first)
poetry config repositories.myrepo https://example.com/simple/
poetry config repositories.myrepo
Defensive patterns

Strategy: validation

Validate before calling

def validate_repo_exists(config, repo_name: str) -> None:
    if config.get(["repositories", repo_name]) is None:
        raise ValueError(f"Repository '{repo_name}' is not defined")

Type guard

def repo_exists(config, repo_name: str) -> bool:
    return config.get(["repositories", repo_name]) is not None

Prevention

When it happens

Trigger: Running `poetry config repositories.myrepo` when no repository named 'myrepo' exists in the configuration. The repo_regex matches and group(1) is 'myrepo', but the config lookup returns None.

Common situations: Typo in the repository name, querying before adding it, or the repository was previously removed.

Related errors


AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04). Data as JSON: /data/errors/4f0952adb37450d8.json. Report an issue: GitHub.