CoplayDev/unity-mcp · error · InvalidOperationException
Install Dir is invalid and cannot be resolved: {installDir}
Error message
Install Dir is invalid and cannot be resolved: {installDir} What it means
ExpandPath performs tilde expansion then Path.GetFullPath; if that throws (path too long, security exception, unreachable root, malformed), ResolveAndValidateInstallPath wraps it in this message with the original exception as inner.
Source
Thrown at MCPForUnity/Editor/Setup/SkillSyncService.cs:683
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;
}
internal static string ExpandPath(string path)
{
if (string.IsNullOrWhiteSpace(path))
{
return string.Empty;
}
var expanded = path.Trim();View on GitHub (pinned to c21bf496bc)
Solutions
- Use a shorter absolute path.
- Check folder and parent-directory permissions.
- Avoid deeply nested or unusually structured paths.
- Inspect the inner exception in the log for the specific GetFullPath failure.
Defensive patterns
Strategy: validation
Validate before calling
try { _ = Path.GetFullPath(installDir.Trim()); }
catch (Exception ex) { throw new ArgumentException("Install dir cannot be resolved.", ex); } Prevention
- Use short, absolute paths to avoid length/resolution failures.
- Check permissions on the target and parent directories.
- Inspect the inner exception for the specific GetFullPath cause.
When it happens
Trigger: Path exceeds system length limits at GetFullPath; a SecurityException denies path resolution; the expanded path references a drive/root that cannot be resolved on the current platform.
Common situations: Very deep nested path on Windows; running under restricted permissions; mixing POSIX separators on a system that rejects them.
Related errors
- Failed to write config file '{path}': {ex.Message}
- Selected folder does not exist.
- The selected uvx executable does not exist
- The selected Claude CLI executable does not exist
- Install Dir contains unmanaged files. Please choose an empty
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/d6270db690dfeb38.
Report an issue: GitHub.