{"record":{"id":"1ede028f94023fd9","repo":"PrefectHQ/fastmcp","slug":"failed-to-add-requirements-e-stderr","errorCode":null,"errorMessage":"Failed to add requirements: {e.stderr}","messagePattern":"Failed to add requirements: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/utilities/mcp_server_config/v1/environments/uv.py","lineNumber":231,"sourceCode":"            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,\n                    capture_output=True,\n                    text=True,\n                )\n            except subprocess.CalledProcessError as e:\n                logger.error(f\"Failed to add requirements: {e.stderr}\")\n                raise RuntimeError(f\"Failed to add requirements: {e.stderr}\") from e\n\n        # Add editable packages if specified\n        if self.editable:\n            editable_paths = [str(Path(e).resolve()) for e in self.editable]\n            logger.debug(f\"Adding editable packages: {', '.join(editable_paths)}\")\n            try:\n                subprocess.run(\n                    [\n                        \"uv\",\n                        \"add\",\n                        \"--editable\",\n                        *editable_paths,\n                        \"--no-sync\",\n                        \"--project\",\n                        str(output_dir),\n                    ],\n                    check=True,\n                    capture_output=True,","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/utilities/mcp_server_config/v1/environments/uv.py#L213-L249","documentation":"prepare() runs `uv add -r <requirements.txt> --no-sync --project <dir>` and raises this RuntimeError when uv exits nonzero. It means uv could not read or resolve the requirements file configured as environment.requirements. uv's stderr is in the message.","triggerScenarios":"prepare() with environment.requirements set to a file that does not exist, is not readable, contains an invalid line (bad PEP 508 spec, bad -e/-r line), or whose pins conflict with the already-added dependencies + fastmcp.","commonSituations":"Path typo or requirements.txt resolved from the wrong working directory (paths resolve relative to CWD, not the config file); a requirements file generated for pip with uv-unsupported flags; conflicting pins between requirements.txt and environment.dependencies; file edited by a teammate with an unparsable line.","solutions":["Check the file exists at the resolved absolute path: `ls -l $(realpath requirements.txt)`; fix the path in the config — remember it resolves from the process CWD.","Read e.stderr for the offending line number and fix that line's specifier or remove uv-unsupported options.","Test `uv add -r requirements.txt --no-sync --project /tmp/t` directly to reproduce.","Resolve pin conflicts between requirements.txt and environment.dependencies reported in stderr.","Freeze from a known-good env if versions drift: `uv pip freeze > requirements.txt`."],"exampleFix":"// before\n\"requirements\": \"../requirements/prod.txt\"  # run from repo root: file not found\n\n// after\n\"requirements\": \"requirements/prod.txt\"  // correct relative to CWD, or use absolute path","handlingStrategy":"validation","validationCode":"import pathlib\n\nreq = cfg.environment.requirements\nif req:\n    p = pathlib.Path(req).resolve()\n    assert p.is_file(), f\"requirements file missing: {p}\"\n    for i, line in enumerate(p.read_text().splitlines(), 1):\n        s = line.strip()\n        if s and not s.startswith(\"#\"):\n            assert not s.startswith(\"-e \"), f\"uv add -r may reject option line {i}: {s}\"","typeGuard":null,"tryCatchPattern":"try:\n    await env.prepare(output_dir)\nexcept RuntimeError as e:\n    if str(e).startswith(\"Failed to add requirements\"):\n        print(e)  # stderr names the bad line/conflict in requirements.txt\n    else:\n        raise","preventionTips":["Use absolute paths or verify the process CWD the config resolves from","Keep requirements.txt pip- and uv-compatible (no exotic options)","Freeze from a known-good environment to avoid drifting pins","Cross-check requirements.txt pins against environment.dependencies for conflicts"],"tags":["uv","requirements-txt","dependency-resolution","environment-setup"],"backgroundTag":"requirements-file-resolution-failed","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}