PrefectHQ/fastmcp · error · RuntimeError
Failed to sync dependencies: {e.stderr}
Error message
Failed to sync dependencies: {e.stderr} What it means
prepare() finishes with `uv sync --project <dir>` to install everything declared in the generated project, and raises this RuntimeError on nonzero exit. Earlier `uv add` steps only record dependencies (--no-sync); this final sync is where actual install/resolve errors surface, including lockfile and wheel-build failures. uv's stderr is in the message.
Source
Thrown at fastmcp_slim/fastmcp/utilities/mcp_server_config/v1/environments/uv.py:269
)
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
- Read e.stderr for the failing package: add missing system build tools/headers (gcc, python3-dev) or pin a version with prebuilt wheels for your Python.
- Fix transitive conflicts by loosening the offending pin reported in the resolution error.
- Delete the generated environment and retry fresh: `rm -rf <output_dir>` (or the fastmcp-env dir) so uv regenerates pyproject.toml/uv.lock.
- Clear uv's cache if installs corrupt: `uv cache clean`, then re-run.
- Try a different `python` version in the environment config where all your deps ship wheels.
Example fix
// before (build failure on Python 3.13) "python": "3.13", "dependencies": ["somepkg==1.2"] # no cp313 wheel, needs old Cython // after "python": "3.12", "dependencies": ["somepkg>=1.3"] # wheels available
Defensive patterns
Strategy: try-catch
Validate before calling
import subprocess, tempfile
# dry-run the full install in a scratch project before prepare()
with tempfile.TemporaryDirectory() as d:
subprocess.run(["uv", "init", "--project", d, "--name", "probe"], check=True, capture_output=True)
r = subprocess.run(["uv", "add", "fastmcp", *(cfg.environment.dependencies or []), "--project", d], capture_output=True, text=True)
if r.returncode != 0:
raise SystemExit(f"sync would fail: {r.stderr}") Try / catch
try:
await env.prepare(output_dir)
except RuntimeError as e:
if str(e).startswith("Failed to sync dependencies"):
# regenerate the env project from scratch, then retry once
shutil.rmtree(output_dir, ignore_errors=True)
await env.prepare(output_dir)
else:
raise Prevention
- Choose a python version where all dependencies publish wheels
- Delete stale fastmcp-env output dirs when switching dependency sets
- Run `uv cache clean` if installs behave inconsistently
- Ensure build toolchains (gcc, python headers) exist when source builds are possible
- Pre-release deps in a scratch project to catch lock conflicts early
When it happens
Trigger: prepare() when the combined dependency set (dependencies + requirements + editable + fastmcp) resolves at add-time but fails at install: transitive conflicts discovered during lock, a wheel/source build failure, unavailable Python matching the pinned version, or a corrupted cache/lockfile in the persistent output_dir.
Common situations: A dependency has no wheel for the pinned Python (e.g. older package on 3.13) and source build fails for missing compilers/headers; conflicting transitive pins; a stale fastmcp-env project dir with a hand-edited pyproject.toml or broken uv.lock; disk full or read-only cache directory.
Related errors
- Failed to pin Python version: {e.stderr}
- Failed to add dependencies: {e.stderr}
- Failed to add requirements: {e.stderr}
- Failed to add editable packages: {e.stderr}
- uv is not installed. Please install it with: curl -LsSf http
AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29).
Data as JSON: /api/errors/04ef09c6abb106a3.
Report an issue: GitHub.