CoplayDev/unity-mcp · error · InvalidOperationException
Install Dir contains unmanaged files. Please choose an empty
Error message
Install Dir contains unmanaged files. Please choose an empty folder or an existing unity-mcp-skill folder.
What it means
EnsureManagedInstallRoot refuses to manage a directory that already contains files but lacks the .unity-mcp-skill-sync ownership marker and does not match the legacy skill-folder shape (must contain SKILL.md and only top-level dirs that exist remotely). This prevents the sync from deleting unrelated user files.
Source
Thrown at MCPForUnity/Editor/Setup/SkillSyncService.cs:542
return map;
}
private static void EnsureManagedInstallRoot(
string installPath,
ICollection<string> localRelativePaths,
ICollection<string> remoteRelativePaths,
StringComparer pathComparer)
{
var markerPath = Path.Combine(installPath, SyncOwnershipMarker);
if (File.Exists(markerPath))
{
return;
}
if (localRelativePaths.Count > 0 && !CanAdoptLegacyManagedRoot(localRelativePaths, remoteRelativePaths, pathComparer))
{
throw new InvalidOperationException(
"Install Dir contains unmanaged files. " +
"Please choose an empty folder or an existing unity-mcp-skill folder.");
}
File.WriteAllText(markerPath, "managed-by-unity-mcp-skill-sync");
}
private static bool CanAdoptLegacyManagedRoot(
ICollection<string> localRelativePaths,
ICollection<string> remoteRelativePaths,
StringComparer pathComparer)
{
if (localRelativePaths.Count == 0)
{
return true;
}
var remoteTopLevels = new HashSet<string>(pathComparer);View on GitHub (pinned to c21bf496bc)
Solutions
- Choose an empty folder as the install directory.
- Or choose an existing unity-mcp-skill folder that contains the .unity-mcp-skill-sync marker.
- Move unrelated files out of the target folder before syncing.
- If adopting a legacy skill folder, ensure it has SKILL.md and matching top-level dirs.
Defensive patterns
Strategy: validation
Validate before calling
var marker = Path.Combine(installDir, ".unity-mcp-skill-sync");
if (Directory.Exists(installDir) && Directory.EnumerateFileSystemEntries(installDir).Any() && !File.Exists(marker))
{
throw new InvalidOperationException("Install dir has unmanaged content. Pick an empty folder or an existing unity-mcp-skill folder.");
} Prevention
- Dedicate a folder to skill sync; do not reuse folders with other content.
- Do not delete the .unity-mcp-skill-sync marker file.
- Pre-validate the chosen directory in the UI before starting a sync.
When it happens
Trigger: Install dir pointed at a non-empty folder with foreign content (project root, Desktop, a sibling package); a previous sync's marker was deleted; the folder has files whose top-level segments do not match the remote layout.
Common situations: User picked the wrong folder in the directory dialog; reused a folder that held other content; marker file was manually removed or gitignored away.
Related errors
- Failed to write config file '{path}': {ex.Message}
- The selected uvx executable does not exist
- The selected Claude CLI executable does not exist
- Install Dir is invalid and cannot be resolved: {installDir}
- 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/a84540a7cdb54414.
Report an issue: GitHub.