{"record":{"id":"04ef09c6abb106a3","repo":"PrefectHQ/fastmcp","slug":"failed-to-sync-dependencies-e-stderr","errorCode":null,"errorMessage":"Failed to sync dependencies: {e.stderr}","messagePattern":"Failed to sync dependencies: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/utilities/mcp_server_config/v1/environments/uv.py","lineNumber":269,"sourceCode":"                )\n            except subprocess.CalledProcessError as e:\n                logger.error(f\"Failed to add editable packages: {e.stderr}\")\n                raise RuntimeError(\n                    f\"Failed to add editable packages: {e.stderr}\"\n                ) from e\n\n        # Final sync to install everything\n        logger.info(\"Installing dependencies...\")\n        try:\n            subprocess.run(\n                [\"uv\", \"sync\", \"--project\", str(output_dir)],\n                check=True,\n                capture_output=True,\n                text=True,\n            )\n        except subprocess.CalledProcessError as e:\n            logger.error(f\"Failed to sync dependencies: {e.stderr}\")\n            raise RuntimeError(f\"Failed to sync dependencies: {e.stderr}\") from e\n\n        logger.info(f\"Environment prepared successfully in {output_dir}\")\n","sourceCodeStart":251,"sourceCodeEnd":272,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/utilities/mcp_server_config/v1/environments/uv.py#L251-L272","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (build failure on Python 3.13)\n\"python\": \"3.13\", \"dependencies\": [\"somepkg==1.2\"]  # no cp313 wheel, needs old Cython\n\n// after\n\"python\": \"3.12\", \"dependencies\": [\"somepkg>=1.3\"]  # wheels available","handlingStrategy":"try-catch","validationCode":"import subprocess, tempfile\n\n# dry-run the full install in a scratch project before prepare()\nwith tempfile.TemporaryDirectory() as d:\n    subprocess.run([\"uv\", \"init\", \"--project\", d, \"--name\", \"probe\"], check=True, capture_output=True)\n    r = subprocess.run([\"uv\", \"add\", \"fastmcp\", *(cfg.environment.dependencies or []), \"--project\", d], capture_output=True, text=True)\n    if r.returncode != 0:\n        raise SystemExit(f\"sync would fail: {r.stderr}\")","typeGuard":null,"tryCatchPattern":"try:\n    await env.prepare(output_dir)\nexcept RuntimeError as e:\n    if str(e).startswith(\"Failed to sync dependencies\"):\n        # regenerate the env project from scratch, then retry once\n        shutil.rmtree(output_dir, ignore_errors=True)\n        await env.prepare(output_dir)\n    else:\n        raise","preventionTips":["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"],"tags":["uv","dependency-install","environment-setup","build"],"backgroundTag":"uv-sync-install-failed","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}