CoplayDev/unity-mcp · error · InvalidOperationException

Missing synced file: {remoteEntry.Key}

Error message

Missing synced file: {remoteEntry.Key}

What it means

ValidateFileHashes runs after ApplyPlan writes all files. For each remote file it resolves the local path and checks File.Exists; a missing file means a write silently failed or the file disappeared, so the sync is reported as inconsistent rather than silently incomplete.

Source

Thrown at MCPForUnity/Editor/Setup/SkillSyncService.cs:475

                var targetFile = ResolvePathUnderRoot(targetRoot, relativePath, pathComparison);
                if (File.Exists(targetFile))
                {
                    File.Delete(targetFile);
                }
            }

            RemoveEmptyDirectories(targetRoot);
        }

        private static void ValidateFileHashes(string installRoot, Dictionary<string, string> remoteFiles, StringComparison pathComparison, Action<string> log)
        {
            var checkedCount = 0;
            foreach (var remoteEntry in remoteFiles)
            {
                var localPath = ResolvePathUnderRoot(installRoot, remoteEntry.Key, pathComparison);
                if (!File.Exists(localPath))
                {
                    throw new InvalidOperationException($"Missing synced file: {remoteEntry.Key}");
                }

                var localBlobSha = ComputeGitBlobSha1(localPath);
                if (!string.Equals(localBlobSha, remoteEntry.Value, StringComparison.Ordinal))
                {
                    throw new InvalidOperationException($"File hash mismatch: {remoteEntry.Key} ({ShortHash(localBlobSha)} != {ShortHash(remoteEntry.Value)})");
                }

                checkedCount++;
            }

            log?.Invoke($"Hash checks passed ({checkedCount}/{remoteFiles.Count}).");
        }

        internal static string ComputeGitBlobSha1(string filePath)
        {
            var bytes = File.ReadAllBytes(filePath);
            return ComputeGitBlobSha1(bytes);

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Shorten the install directory path to stay under Windows' 260-char limit.
  2. Free disk space and confirm write permissions on the install dir.
  3. Exclude the install dir from antivirus/OneDrive real-time scanning.
  4. Retry the sync after fixing the environment.
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: File write failed (disk full, permission denied); antivirus/quarantine removed the file immediately; Windows MAX_PATH (260 char) exceeded so the write path was invalid; another process moved/deleted the file.

Common situations: Windows long-path limit on deep install directories; OneDrive/Defender real-time scanning quarantines new files; disk full; install dir on a read-only mount.

Related errors


AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13). Data as JSON: /api/errors/7c979fd3b7a2845e. Report an issue: GitHub.