PrefectHQ/fastmcp · error · RuntimeError

Failed to add editable packages: {e.stderr}

Error message

Failed to add editable packages: {e.stderr}

What it means

prepare() runs `uv add --editable <paths> --no-sync --project <dir>` and raises this RuntimeError when uv exits nonzero. It means uv could not add one of the configured editable package directories, typically because the directory is not a buildable Python package. uv's stderr is in the message.

Source

Thrown at fastmcp_slim/fastmcp/utilities/mcp_server_config/v1/environments/uv.py:254

            logger.debug(f"Adding editable packages: {', '.join(editable_paths)}")
            try:
                subprocess.run(
                    [
                        "uv",
                        "add",
                        "--editable",
                        *editable_paths,
                        "--no-sync",
                        "--project",
                        str(output_dir),
                    ],
                    check=True,
                    capture_output=True,
                    text=True,
                )
            except subprocess.CalledProcessError as e:
                logger.error(f"Failed to add editable packages: {e.stderr}")
                raise RuntimeError(
                    f"Failed to add editable packages: {e.stderr}"
                ) from e

        # Final sync to install everything
        logger.info("Installing dependencies...")
        try:
            subprocess.run(
                ["uv", "sync", "--project", str(output_dir)],
                check=True,
                capture_output=True,
                text=True,
            )
        except subprocess.CalledProcessError as e:
            logger.error(f"Failed to sync dependencies: {e.stderr}")
            raise RuntimeError(f"Failed to sync dependencies: {e.stderr}") from e

        logger.info(f"Environment prepared successfully in {output_dir}")

View on GitHub (pinned to 1f02114297)

Solutions

  1. Verify each editable path exists and contains a valid build file (pyproject.toml or setup.py); fix the path in environment.editable.
  2. Read e.stderr: if it's a build error, fix the package's build config or add the missing build requirement.
  3. Test one path manually: `uv add --editable ./my-package --no-sync --project /tmp/t` to identify the offending entry.
  4. If you just want the package importable without installing, remove it from editable and rely on CWD/PYTHONPATH instead.
  5. Regenerate/repair packaging metadata for the local package (e.g. `uv build` in the package dir to check it builds standalone).

Example fix

// before
"editable": ["."]  # repo root has no pyproject.toml

// after
"editable": ["packages/my-server"]  # directory containing pyproject.toml
Defensive patterns

Strategy: validation

Validate before calling

import pathlib

for e in (cfg.environment.editable or []):
    p = pathlib.Path(e).resolve()
    assert p.is_dir(), f"editable path missing: {p}"
    has_meta = (p / "pyproject.toml").is_file() or (p / "setup.py").is_file()
    assert has_meta, f"{p} has no pyproject.toml/setup.py — not installable"

Try / catch

try:
    await env.prepare(output_dir)
except RuntimeError as e:
    if str(e).startswith("Failed to add editable packages"):
        print(e)  # stderr identifies the unbuildable path
    else:
        raise

Prevention

When it happens

Trigger: prepare() with environment.editable containing a path that doesn't exist, isn't a directory with a pyproject.toml/setup.py, or whose package fails to build (missing build backend, syntax error at build time).

Common situations: Pointing editable at the repo root instead of the package dir lacking pyproject.toml; a typo'd or non-resolved relative path; a local package with a broken hatch/setuptools config; a package needing a build dependency not present.

Related errors


AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29). Data as JSON: /api/errors/53b12424eea9b970. Report an issue: GitHub.