{"record":{"id":"4effa35a665bb2de","repo":"PrefectHQ/fastmcp","slug":"failed-to-add-dependencies-e-stderr","errorCode":null,"errorMessage":"Failed to add dependencies: {e.stderr}","messagePattern":"Failed to add dependencies: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/utilities/mcp_server_config/v1/environments/uv.py","lineNumber":207,"sourceCode":"        dependencies = (self.dependencies or []) + [\"fastmcp\"]\n        logger.debug(f\"Adding dependencies: {', '.join(dependencies)}\")\n        try:\n            subprocess.run(\n                [\n                    \"uv\",\n                    \"add\",\n                    *dependencies,\n                    \"--no-sync\",\n                    \"--project\",\n                    str(output_dir),\n                ],\n                check=True,\n                capture_output=True,\n                text=True,\n            )\n        except subprocess.CalledProcessError as e:\n            logger.error(f\"Failed to add dependencies: {e.stderr}\")\n            raise RuntimeError(f\"Failed to add dependencies: {e.stderr}\") from e\n\n        # Add requirements file if specified\n        if self.requirements:\n            logger.debug(f\"Adding requirements from {self.requirements}\")\n            # Resolve requirements path relative to current directory\n            req_path = Path(self.requirements).resolve()\n            try:\n                subprocess.run(\n                    [\n                        \"uv\",\n                        \"add\",\n                        \"-r\",\n                        str(req_path),\n                        \"--no-sync\",\n                        \"--project\",\n                        str(output_dir),\n                    ],\n                    check=True,","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/utilities/mcp_server_config/v1/environments/uv.py#L189-L225","documentation":"prepare() runs `uv add <deps> fastmcp --no-sync --project <dir>` and wraps any nonzero exit in this RuntimeError. It means uv failed to resolve or add the configured `dependencies` (plus fastmcp itself) to the generated project's pyproject.toml. uv's stderr is embedded in the message.","triggerScenarios":"prepare() with environment.dependencies containing a package name/spec uv cannot resolve: nonexistent package, an invalid PEP 508 specifier, or a version that conflicts with fastmcp or another entry (uv resolves all adds together).","commonSituations":"Typo'd package name (\"reqests\"); pinning fastmcp==1.x alongside an installed fastmcp 2.x wheel requirement; conflicting pins like httpx<0.24 with a dep requiring newer httpx; private packages not reachable from the configured index.","solutions":["Read e.stderr: fix the exact package/spec uv reports (typo, nonexistent package, invalid specifier).","Relax or remove the conflicting version pin reported in the resolution error (e.g. fastmcp>=2.0 instead of fastmcp==2.3.1 if it conflicts).","Verify the package exists on the configured index; add private indexes via UV_INDEX_URL/--index if needed.","Test resolution outside fastmcp: `uv add <dep> --no-sync --project <tmpdir>` to reproduce and iterate quickly.","Temporarily remove entries from environment.dependencies to isolate which one breaks resolution."],"exampleFix":"// before\n\"dependencies\": [\"fastmcp==2.3.1\", \"pandas<2.0\"]  # conflicts with deps needing pandas>=2\n\n// after\n\"dependencies\": [\"fastmcp>=2.0\", \"pandas>=2.0\"]","handlingStrategy":"validation","validationCode":"import subprocess, tempfile, pathlib\n\ndeps = cfg.environment.dependencies or []\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\", *deps, \"fastmcp\", \"--no-sync\", \"--project\", d], capture_output=True, text=True)\n    if r.returncode != 0:\n        raise SystemExit(f\"deps unresolvable: {r.stderr}\")","typeGuard":null,"tryCatchPattern":"try:\n    await env.prepare(output_dir)\nexcept RuntimeError as e:\n    if str(e).startswith(\"Failed to add dependencies\"):\n        print(e)  # stderr names the unresolvable spec; fix config, then retry\n    else:\n        raise","preventionTips":["Validate every entry is a well-formed PEP 508 specifier before adding it to config","Avoid hard equality pins on fastmcp or your deps' transitive requirements","Test the dependency set in a scratch uv project first","Document required private index config (UV_INDEX_URL) for teammates"],"tags":["uv","dependency-resolution","pip","environment-setup"],"backgroundTag":"dependency-resolution-failed","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}