{"record":{"id":"75042766a14f3cff","repo":"github/copilot-sdk","slug":"could-not-determine-a-napi-rs-prebuilds-folder-for","errorCode":null,"errorMessage":"Could not determine a napi-rs prebuilds folder for FFI hosting.","messagePattern":"Could not determine a napi-rs prebuilds folder for FFI hosting\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Client.cs","lineNumber":2609,"sourceCode":"                ? \"linuxmusl\"\n                : \"linux\";\n        }\n        else if (OperatingSystem.IsMacOS()) platform = \"darwin\";\n        else return null;\n\n        var arch = System.Runtime.InteropServices.RuntimeInformation.OSArchitecture switch\n        {\n            System.Runtime.InteropServices.Architecture.X64 => \"x64\",\n            System.Runtime.InteropServices.Architecture.Arm64 => \"arm64\",\n            _ => null,\n        };\n\n        return arch != null ? $\"{platform}-{arch}\" : null;\n    }\n\n    private static string GetNapiPrebuildsFolderOrThrow() =>\n        GetNapiPrebuildsFolder()\n        ?? throw new InvalidOperationException(\"Could not determine a napi-rs prebuilds folder for FFI hosting.\");\n\n    private static (string FileName, IEnumerable<string> Args) ResolveCliCommand(string cliPath, IEnumerable<string> args)\n    {\n        var isJsFile = cliPath.EndsWith(\".js\", StringComparison.OrdinalIgnoreCase);\n\n        if (isJsFile)\n        {\n            return (\"node\", new[] { cliPath }.Concat(args));\n        }\n\n        return (cliPath, args);\n    }\n\n    private async Task<Connection> ConnectToServerAsync(Process? cliProcess, string? tcpHost, int? tcpPort, ProcessStderrPump? stderrPump, CancellationToken cancellationToken, FfiRuntimeHost? ffiHost = null)\n    {\n        var setupTimestamp = Stopwatch.GetTimestamp();\n        NetworkStream? networkStream = null;\n        JsonRpc? rpc = null;","sourceCodeStart":2591,"sourceCodeEnd":2627,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/dotnet/src/Client.cs#L2591-L2627","documentation":"GetNapiPrebuildsFolder builds the `<node-platform>-<arch>` folder name (e.g. win32-x64) from the current runtime's platform and architecture. If either cannot be determined it returns null and GetNapiPrebuildsFolderOrThrow throws this InvalidOperationException. It is a guard so FFI library resolution never silently probes an invalid prebuilds path.","triggerScenarios":"FFI startup calls GetNapiPrebuildsFolderOrThrow while RuntimeInformation's OSArchitecture/ProcessArchitecture maps to an unknown platform or architecture (null result).","commonSituations":"Running on an exotic or unsupported platform/arch combination (e.g. linux-armel, freebsd) or inside an environment where the .NET runtime cannot report the architecture; mismatched self-contained publish settings.","solutions":["Run the app on a supported platform/arch (win32/win-arm64, linux-x64/arm64, darwin-x64/arm64).","Check RuntimeInformation.OSArchitecture and ProcessArchitecture locally to see what the runtime reports; fix RID mismatch in the publish profile if it reports an odd value.","Use stdio (CLI process) hosting instead of FFI hosting on unsupported platforms."],"exampleFix":"// before: FFI hosting on an untested arch\ncopilot = new CopilotClient(); // throws on e.g. linux-armel\n\n// after: gate FFI hosting on known arches\nvar arch = RuntimeInformation.ProcessArchitecture;\nbool ffiSupported = arch is Architecture.X64 or Architecture.Arm64;\ncopilot = ffiSupported ? new CopilotClient() : new CopilotClient(useStdio: true);","handlingStrategy":"validation","validationCode":"var arch = RuntimeInformation.ProcessArchitecture;\nvar os = RuntimeInformation.OSDescription;\nbool supported = arch is Architecture.X64 or Architecture.Arm64;\nif (!supported) throw new PlatformNotSupportedException(os);","typeGuard":null,"tryCatchPattern":"try { folder = GetNapiPrebuildsFolder(); }\ncatch (InvalidOperationException) { /* fall back to stdio hosting */ }","preventionTips":["Deploy only on supported RIDs (win/linux/darwin x64/arm64)","Check ProcessArchitecture in a smoke test before startup","Prefer stdio hosting on niche platforms"],"tags":["ffi","platform","startup","dotnet"],"backgroundTag":"unsupported-platform","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}