CoplayDev/unity-mcp · error · Exception
Failed to download {packageId}: {request.error}
Error message
Failed to download {packageId}: {request.error} What it means
Thrown by RoslynInstaller.Install when a UnityWebRequest.Get against the NuGet flat container (api.nuget.org) does not return Success. The installer downloads .nupkg zips and extracts the Roslyn DLLs that power the runtime_compilation tool; a failed download aborts the whole install.
Source
Thrown at MCPForUnity/Editor/Setup/RoslynInstaller.cs:99
{
EditorUtility.DisplayProgressBar(
"Installing Roslyn",
$"Downloading {packageId} v{pkgVersion}...",
(float)i / NuGetEntries.Length);
}
string url =
$"https://api.nuget.org/v3-flatcontainer/{packageId}/{pkgVersion}/{packageId}.{pkgVersion}.nupkg";
using (var request = UnityWebRequest.Get(url))
{
request.timeout = 30;
request.SendWebRequest();
while (!request.isDone)
System.Threading.Thread.Sleep(50);
if (request.result != UnityWebRequest.Result.Success)
throw new Exception($"Failed to download {packageId}: {request.error}");
byte[] nupkgBytes = request.downloadHandler.data;
byte[] dllBytes = ExtractFileFromZip(nupkgBytes, dllPathInZip);
if (dllBytes == null)
{
Debug.LogError($"[MCP] Could not find {dllPathInZip} in {packageId}.{pkgVersion}.nupkg");
continue;
}
string destPath = Path.Combine(destFolder, dllName);
File.WriteAllBytes(destPath, dllBytes);
Debug.Log($"[MCP] Extracted {dllName} ({dllBytes.Length / 1024}KB) → Assets/{PluginsRelPath}/{dllName}");
}
}
if (interactive)
EditorUtility.DisplayProgressBar("Installing Roslyn", "Refreshing assets...", 0.95f);View on GitHub (pinned to c21bf496bc)
Solutions
- Verify connectivity to https://api.nuget.org from the Unity machine.
- Retry the install once network is stable.
- Manually place the required DLLs (Microsoft.CodeAnalysis 4.12.0, CSharp, System.Collections.Immutable 8.0.0, System.Reflection.Metadata 8.0.0, System.Runtime.CompilerServices.Unsafe 6.0.0) into Assets/Plugins/Roslyn.
- Configure a working proxy in Unity/OS settings if behind a corporate network.
Defensive patterns
Strategy: retry
Try / catch
try
{
RoslynInstaller.Install(interactive: true);
}
catch (Exception ex) when (ex.Message.Contains("Failed to download"))
{
Debug.LogError($"NuGet download failed (network): {ex.Message}. Place DLLs manually in Assets/Plugins/Roslyn.");
} Prevention
- Confirm api.nuget.org is reachable before installing in restricted networks.
- Pre-stage the DLLs in Assets/Plugins/Roslyn for air-gapped machines.
- Retry on transient failures; treat persistent failure as a network/proxy issue.
When it happens
Trigger: Network is offline or api.nuget.org is unreachable; the 30-second request timeout is exceeded on a slow link; a corporate proxy or SSL/certificate error fails the request; the specific package/version was delisted from NuGet.
Common situations: Corporate firewall blocks nuget.org; air-gapped Unity machine; transient NuGet outage; slow connection timing out at the hardcoded 30s.
Related errors
- Port must be positive.
- Port {port} is already in use.
- No available ports found in range {DefaultPort}-{DefaultPort
- fal submit returned no request_id: {truncated_response}
- fal {phase} failed (status={res?.Status}): {detail}
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/dfa58694a7acd6fb.
Report an issue: GitHub.