{"record":{"id":"ebe4dd7dd6a47fe0","repo":"CoplayDev/unity-mcp","slug":"could-not-find-packages-manifest-json-from-current","errorCode":null,"errorMessage":"Could not find Packages/manifest.json from current directory. Use --manifest to specify a path.","messagePattern":"Could not find Packages/manifest\\.json from current directory\\. Use --manifest to specify a path\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"mcp_source.py","lineNumber":79,"sourceCode":"def detect_branch(repo: pathlib.Path) -> str:\n    return run_git(repo, \"rev-parse\", \"--abbrev-ref\", \"HEAD\")\n\n\ndef detect_origin(repo: pathlib.Path) -> str:\n    url = run_git(repo, \"remote\", \"get-url\", \"origin\")\n    return normalize_origin_to_https(url)\n\n\ndef find_manifest(explicit: str | None) -> pathlib.Path:\n    if explicit:\n        return pathlib.Path(explicit).resolve()\n    # Walk up from CWD looking for Packages/manifest.json\n    cur = pathlib.Path.cwd().resolve()\n    for parent in [cur, *cur.parents]:\n        candidate = parent / \"Packages\" / \"manifest.json\"\n        if candidate.exists():\n            return candidate\n    raise FileNotFoundError(\n        \"Could not find Packages/manifest.json from current directory. Use --manifest to specify a path.\")\n\n\ndef read_json(path: pathlib.Path) -> dict:\n    with path.open(\"r\", encoding=\"utf-8\") as f:\n        return json.load(f)\n\n\ndef write_json(path: pathlib.Path, data: dict) -> None:\n    with path.open(\"w\", encoding=\"utf-8\") as f:\n        json.dump(data, f, indent=2)\n        f.write(\"\\n\")\n\n\ndef build_options(repo_root: pathlib.Path, branch: str, origin_https: str):\n    upstream_main = \"https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main\"\n    upstream_beta = \"https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#beta\"\n    # Ensure origin is https","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/mcp_source.py#L61-L97","documentation":"Raised by find_manifest in mcp_source.py when no Packages/manifest.json is found by walking up from the current working directory. mcp_source.py edits the Unity package manifest to switch the MCP for Unity package source, so it must locate a Unity project root.","triggerScenarios":"The script is run from a directory that is not inside (nor a parent of) a Unity project, and --manifest was not supplied. The walk over [cwd, *cwd.parents] finds no Packages/manifest.json.","commonSituations":"Running mcp_source.py from the MCP-for-Unity repo root instead of from within a Unity project; CWD is a temp/build dir; the Unity project uses a non-standard layout without a Packages folder.","solutions":["Run the script from inside the Unity project directory (the one containing Packages/manifest.json).","Pass --manifest /path/to/UnityProject/Packages/manifest.json explicitly.","Verify the target project actually has a Packages/manifest.json (i.e., is a real Unity project)."],"exampleFix":"# before (run from repo root)\npython mcp_source.py main\n# after\npython mcp_source.py main --manifest /abs/path/UnityProject/Packages/manifest.json","handlingStrategy":"validation","validationCode":"import pathlib\ncur = pathlib.Path.cwd().resolve()\nmanifest = next((p/'Packages'/'manifest.json' for p in [cur,*cur.parents] if (p/'Packages'/'manifest.json').exists()), None)\nif manifest is None and not args.manifest:\n    raise SystemExit('No Packages/manifest.json found; pass --manifest')","typeGuard":"def is_unity_project_dir(p: pathlib.Path) -> bool:\n    return (p / 'Packages' / 'manifest.json').exists()","tryCatchPattern":"try:\n    manifest = find_manifest(args.manifest)\nexcept FileNotFoundError as e:\n    print(e); sys.exit(1)","preventionTips":["Run mcp_source.py from inside the Unity project","Pass --manifest explicitly in scripts","Confirm the target dir is a real Unity project"],"tags":["tooling","filesystem","unity-project","mcp-source"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}