CoplayDev/unity-mcp · error · FileNotFoundError
Package file not found: {PACKAGE_JSON}
Error message
Package file not found: {PACKAGE_JSON} What it means
Raised as FileNotFoundError by load_package_version() when MCPForUnity/package.json does not exist on disk. This file is the source of truth for the Unity package version and is the first thing update_versions.py reads (when --version is not supplied). REPO_ROOT is derived from the script's own location (parents[1]), so a wrong CWD or relocated script produces a bad path.
Source
Thrown at tools/update_versions.py:48
import argparse
import json
import re
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
PACKAGE_JSON = REPO_ROOT / "MCPForUnity" / "package.json"
MANIFEST_JSON = REPO_ROOT / "manifest.json"
PYPROJECT_TOML = REPO_ROOT / "Server" / "pyproject.toml"
SERVER_README = REPO_ROOT / "Server" / "README.md"
ROOT_README = REPO_ROOT / "README.md"
ZH_README = REPO_ROOT / "docs" / "i18n" / "README-zh.md"
def load_package_version() -> str:
"""Load version from package.json."""
if not PACKAGE_JSON.exists():
raise FileNotFoundError(f"Package file not found: {PACKAGE_JSON}")
package_data = json.loads(PACKAGE_JSON.read_text(encoding="utf-8"))
version = package_data.get("version")
if not version:
raise ValueError("No version found in package.json")
return version
def update_package_json(new_version: str, dry_run: bool = False) -> bool:
"""Update version in MCPForUnity/package.json."""
if not PACKAGE_JSON.exists():
print(f"Warning: {PACKAGE_JSON.relative_to(REPO_ROOT)} not found")
return False
package_data = json.loads(PACKAGE_JSON.read_text(encoding="utf-8"))
current_version = package_data.get("version", "unknown")View on GitHub (pinned to c21bf496bc)
Solutions
- Confirm the file exists: ls MCPForUnity/package.json from the repo root.
- Run the script from within the repo, or ensure parents[1] of the script path resolves to the actual repo root.
- If you know the version, bypass auto-detection by passing --version explicitly (update_versions.py only calls load_package_version when --version is absent).
Example fix
# before — auto-detect fails because package.json is missing python3 tools/update_versions.py # after — supply version explicitly to skip the missing-file read python3 tools/update_versions.py --version 9.2.0
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
PACKAGE_JSON = Path("MCPForUnity").resolve() / "package.json"
if not PACKAGE_JSON.is_file():
raise SystemExit(f"{PACKAGE_JSON} not found. Run from the repo root or pass --version.") Prevention
- Run update_versions.py from the repo root so REPO_ROOT resolves correctly.
- If package.json is unavailable, pass --version to bypass auto-detection.
- Add a CI step that verifies MCPForUnity/package.json exists before version bumping.
When it happens
Trigger: Running update_versions.py from outside the repo, or with the script copied/moved so that parents[1] doesn't resolve to the real repo root. Also fires in a shallow clone or worktree that excludes the MCPForUnity directory.
Common situations: Script invoked from a different working directory; the repo was only partially cloned; the script was symlinked or copied to a tools/ directory in a different project; MCPForUnity/package.json was deleted or not yet created in a fresh branch.
Related errors
- Source MCPForUnity folder not found: {source_mcp}
- Assets folder not found: {assets_dir}
- Expected file not found: {f}
- No version found in package.json
- Could not generate a unique screenshot filename for '{fullPa
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/8bf6a71ade884374.
Report an issue: GitHub.