{"record":{"id":"1be60b2b8a2c7698","repo":"microsoft/autogen","slug":"failed-to-restore-dotnet-interactive-tool","errorCode":null,"errorMessage":"Failed to restore dotnet interactive tool.","messagePattern":"Failed to restore dotnet interactive tool\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.DotnetInteractive/DotnetInteractiveStdioKernelConnector.cs","lineNumber":33,"sourceCode":"    private string kernelName;\n    private List<SubmitCode> setupCommands = new List<SubmitCode>();\n\n    internal DotnetInteractiveStdioKernelConnector(string workingDirectory, string kernelName = \"root-proxy\")\n    {\n        this.workingDirectory = workingDirectory;\n        this.interactiveService = new InteractiveService(workingDirectory);\n        this.kernelName = kernelName;\n    }\n\n    public DotnetInteractiveStdioKernelConnector RestoreDotnetInteractive()\n    {\n        if (this.interactiveService.RestoreDotnetInteractive())\n        {\n            return this;\n        }\n        else\n        {\n            throw new ArgumentException(\"Failed to restore dotnet interactive tool.\");\n        }\n    }\n\n    public DotnetInteractiveStdioKernelConnector AddPythonKernel(\n        string venv,\n        string kernelName = \"python\")\n    {\n        var magicCommand = $\"#!connect jupyter --kernel-name {kernelName} --kernel-spec {venv}\";\n        var connectCommand = new SubmitCode(magicCommand);\n\n        this.setupCommands.Add(connectCommand);\n\n        return this;\n    }\n\n    public async Task<Kernel> BuildAsync(CancellationToken ct = default)\n    {\n        var compositeKernel = new CompositeKernel();","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.DotnetInteractive/DotnetInteractiveStdioKernelConnector.cs#L15-L51","documentation":"Thrown by DotnetInteractiveStdioKernelConnector.RestoreDotnetInteractive when the underlying InteractiveService.RestoreDotnetInteractive() (which writes config resources and runs 'dotnet tool restore') returns false. This means the dotnet interactive tool could not be installed/restored on disk.","triggerScenarios":"Calling RestoreDotnetInteractive() when the 'dotnet tool restore --configfile RestoreInteractive.config' process fails or times out: no network access to nuget.org, missing .NET SDK on PATH, a corrupt installing directory, or a restore process that exits non-zero.","commonSituations":"Offline or proxied CI environments blocking nuget.org, containers without the dotnet CLI, read-only installing directories, or version conflicts between the Microsoft.DotNet.Interactive tool pinned in the embedded config and available package versions.","solutions":["Verify 'dotnet --version' runs in the same environment and that nuget.org is reachable (check proxy/NuGet config)","Run 'dotnet tool restore' manually in the installing directory to see the real error output","Clear the installing directory and retry so fresh RestoreInteractive.config/dotnet-tools.json are written","Pin a compatible version of the dotnet-interactive tool matching your AutoGen.DotnetInteractive package"],"exampleFix":"// before: connector.RestoreDotnetInteractive(); // throws on restore failure\n// after: diagnose manually first\n// cd <installDir> && dotnet tool restore --configfile RestoreInteractive.config\n// fix network/proxy, then retry connector.RestoreDotnetInteractive();","handlingStrategy":"try-catch","validationCode":"// Pre-flight the environment before restoring\nif (Run(\"dotnet --version\") is null) throw new InvalidOperationException(\"dotnet CLI not on PATH\");\nif (!Directory.Exists(connectorInstallDir)) Directory.CreateDirectory(connectorInstallDir);","typeGuard":null,"tryCatchPattern":"try { connector.RestoreDotnetInteractive(); }\ncatch (ArgumentException e) when (e.Message == \"Failed to restore dotnet interactive tool.\")\n{ /* run 'dotnet tool restore' manually in the install dir to see the error; fix network/proxy; retry */ }","preventionTips":["Verify dotnet SDK and nuget.org reachability in CI before running agents","Keep the installing directory writable and clean between runs"],"tags":["autogen","dotnet-interactive","nuget","environment"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}