CoplayDev/unity-mcp · error · InvalidOperationException
Install Dir contains invalid path characters: {installDir}
Error message
Install Dir contains invalid path characters: {installDir} What it means
ResolveAndValidateInstallPath checks the trimmed path against Path.GetInvalidPathChars() and throws if any illegal character (e.g. <, >, |, ", or control chars) is present. These characters cannot appear in a real filesystem path.
Source
Thrown at MCPForUnity/Editor/Setup/SkillSyncService.cs:673
{
continue;
}
Directory.Delete(directory, false);
}
}
internal static string ResolveAndValidateInstallPath(string installDir)
{
if (string.IsNullOrWhiteSpace(installDir))
{
throw new InvalidOperationException("Install Dir is empty.");
}
var trimmed = installDir.Trim();
if (trimmed.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
{
throw new InvalidOperationException($"Install Dir contains invalid path characters: {installDir}");
}
string expandedPath;
try
{
expandedPath = ExpandPath(trimmed);
}
catch (Exception ex)
{
throw new InvalidOperationException($"Install Dir is invalid and cannot be resolved: {installDir}", ex);
}
if (string.IsNullOrWhiteSpace(expandedPath))
{
throw new InvalidOperationException("Install Dir resolved to an empty path.");
}
return expandedPath;View on GitHub (pinned to c21bf496bc)
Solutions
- Remove any of <, >, |, ", or control characters from the path.
- Use a plain filesystem path with normal separators.
- If using a template variable, ensure it is resolved before passing the value.
Example fix
// before var installDir = "<project>/Skills"; // after var installDir = "/Users/me/Projects/MyGame/Skills";
Defensive patterns
Strategy: validation
Validate before calling
if (installDir.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
{
throw new ArgumentException($"Install directory contains invalid characters: {installDir}");
} Prevention
- Paste plain filesystem paths, not URLs or templates.
- Resolve template variables before passing the value.
- Avoid smart quotes and angle brackets from rich-text copy-paste.
When it happens
Trigger: User pasted a URL or a copy-paste artifact containing special characters; a template/variable was not substituted and left a literal like '<project>'; input mixed path separators with disallowed chars.
Common situations: Placeholder syntax left in the path; pasted from a rich-text source that inserted smart quotes; URL fragment mistaken for a path.
Related errors
- Install Dir is empty.
- Source path cannot be empty.
- Selected folder does not exist.
- The selected uvx executable does not exist
- The selected Claude CLI executable does not exist
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/9f71fd188230eb3d.
Report an issue: GitHub.