CoplayDev/unity-mcp · critical · PlatformNotSupportedException

No detector available for current platform: {RuntimeInformat

Error message

No detector available for current platform: {RuntimeInformation.OSDescription}

What it means

DependencyManager.GetCurrentPlatformDetector() iterates a fixed list of three detectors (Windows, MacOS, Linux) and picks the first whose CanDetect returns true. If none match, it throws PlatformNotSupportedException. This is a hard guard for unsupported operating systems — the dependency check subsystem cannot detect Python/uv on an unknown platform.

Source

Thrown at MCPForUnity/Editor/Dependencies/DependencyManager.cs:37

        {
            new WindowsPlatformDetector(),
            new MacOSPlatformDetector(),
            new LinuxPlatformDetector()
        };

        private static IPlatformDetector _currentDetector;

        /// <summary>
        /// Get the platform detector for the current operating system
        /// </summary>
        public static IPlatformDetector GetCurrentPlatformDetector()
        {
            if (_currentDetector == null)
            {
                _currentDetector = _detectors.FirstOrDefault(d => d.CanDetect);
                if (_currentDetector == null)
                {
                    throw new PlatformNotSupportedException($"No detector available for current platform: {RuntimeInformation.OSDescription}");
                }
            }
            return _currentDetector;
        }

        /// <summary>
        /// Perform a comprehensive dependency check
        /// </summary>
        public static DependencyCheckResult CheckAllDependencies()
        {
            var result = new DependencyCheckResult();

            try
            {
                var detector = GetCurrentPlatformDetector();
                McpLog.Info($"Checking dependencies on {detector.PlatformName}...", always: false);

                // Check Python

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Run Unity on a supported OS (Windows, macOS, or a standard Linux distribution).
  2. If on an unusual platform, implement a custom IPlatformDetector and insert it into the _detectors list before calling GetCurrentPlatformDetector().
  3. Check RuntimeInformation.OSDescription output to understand why no detector matched.
  4. Wrap the call in try-catch(PlatformNotSupportedException) and provide a fallback that bypasses dependency detection.

Example fix

// before
var detector = DependencyManager.GetCurrentPlatformDetector();

// after
IPlatformDetector detector;
try { detector = DependencyManager.GetCurrentPlatformDetector(); }
catch (PlatformNotSupportedException ex)
{
    McpLog.Warn($"Unsupported platform, skipping dependency check: {ex.Message}");
    return;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
    !RuntimeInformation.IsOSPlatform(OSPlatform.OSX) &&
    !RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{ /* unsupported platform; skip dependency check */ }

Type guard

public static bool IsPlatformSupported() =>
    RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ||
    RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ||
    RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

Try / catch

try { var detector = DependencyManager.GetCurrentPlatformDetector(); }
catch (PlatformNotSupportedException ex)
{ Debug.LogWarning($"Unsupported platform for dependency detection: {ex.Message}"); }

Prevention

When it happens

Trigger: Running the Unity Editor on a platform that is not Windows, macOS, or Linux (e.g., FreeBSD, a custom OS), or where RuntimeInformation.OSDescription does not match any detector's platform check.

Common situations: Unity running under WSLg or an unusual Linux distro where the OS detection string is unexpected. A community port of Unity to a non-standard platform. Running in a container where OS platform detection returns ambiguous results.

Related errors


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