{"record":{"id":"a84540a7cdb54414","repo":"CoplayDev/unity-mcp","slug":"install-dir-contains-unmanaged-files-please-choos","errorCode":null,"errorMessage":"Install Dir contains unmanaged files. Please choose an empty folder or an existing unity-mcp-skill folder.","messagePattern":"Install Dir contains unmanaged files\\. Please choose an empty folder or an existing unity-mcp-skill folder\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Setup/SkillSyncService.cs","lineNumber":542,"sourceCode":"\n            return map;\n        }\n\n        private static void EnsureManagedInstallRoot(\n            string installPath,\n            ICollection<string> localRelativePaths,\n            ICollection<string> remoteRelativePaths,\n            StringComparer pathComparer)\n        {\n            var markerPath = Path.Combine(installPath, SyncOwnershipMarker);\n            if (File.Exists(markerPath))\n            {\n                return;\n            }\n\n            if (localRelativePaths.Count > 0 && !CanAdoptLegacyManagedRoot(localRelativePaths, remoteRelativePaths, pathComparer))\n            {\n                throw new InvalidOperationException(\n                    \"Install Dir contains unmanaged files. \" +\n                    \"Please choose an empty folder or an existing unity-mcp-skill folder.\");\n            }\n\n            File.WriteAllText(markerPath, \"managed-by-unity-mcp-skill-sync\");\n        }\n\n        private static bool CanAdoptLegacyManagedRoot(\n            ICollection<string> localRelativePaths,\n            ICollection<string> remoteRelativePaths,\n            StringComparer pathComparer)\n        {\n            if (localRelativePaths.Count == 0)\n            {\n                return true;\n            }\n\n            var remoteTopLevels = new HashSet<string>(pathComparer);","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Setup/SkillSyncService.cs#L524-L560","documentation":"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.","triggerScenarios":"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.","commonSituations":"User picked the wrong folder in the directory dialog; reused a folder that held other content; marker file was manually removed or gitignored away.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var marker = Path.Combine(installDir, \".unity-mcp-skill-sync\");\nif (Directory.Exists(installDir) && Directory.EnumerateFileSystemEntries(installDir).Any() && !File.Exists(marker))\n{\n    throw new InvalidOperationException(\"Install dir has unmanaged content. Pick an empty folder or an existing unity-mcp-skill folder.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["filesystem","safety","config"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}