microsoft/autogen · error · ArgumentException

Failed to restore dotnet interactive tool.

Error message

Failed to restore dotnet interactive tool.

What it means

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.

Source

Thrown at dotnet/src/AutoGen.DotnetInteractive/DotnetInteractiveStdioKernelConnector.cs:33

    private string kernelName;
    private List<SubmitCode> setupCommands = new List<SubmitCode>();

    internal DotnetInteractiveStdioKernelConnector(string workingDirectory, string kernelName = "root-proxy")
    {
        this.workingDirectory = workingDirectory;
        this.interactiveService = new InteractiveService(workingDirectory);
        this.kernelName = kernelName;
    }

    public DotnetInteractiveStdioKernelConnector RestoreDotnetInteractive()
    {
        if (this.interactiveService.RestoreDotnetInteractive())
        {
            return this;
        }
        else
        {
            throw new ArgumentException("Failed to restore dotnet interactive tool.");
        }
    }

    public DotnetInteractiveStdioKernelConnector AddPythonKernel(
        string venv,
        string kernelName = "python")
    {
        var magicCommand = $"#!connect jupyter --kernel-name {kernelName} --kernel-spec {venv}";
        var connectCommand = new SubmitCode(magicCommand);

        this.setupCommands.Add(connectCommand);

        return this;
    }

    public async Task<Kernel> BuildAsync(CancellationToken ct = default)
    {
        var compositeKernel = new CompositeKernel();

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Verify 'dotnet --version' runs in the same environment and that nuget.org is reachable (check proxy/NuGet config)
  2. Run 'dotnet tool restore' manually in the installing directory to see the real error output
  3. Clear the installing directory and retry so fresh RestoreInteractive.config/dotnet-tools.json are written
  4. Pin a compatible version of the dotnet-interactive tool matching your AutoGen.DotnetInteractive package

Example fix

// before: connector.RestoreDotnetInteractive(); // throws on restore failure
// after: diagnose manually first
// cd <installDir> && dotnet tool restore --configfile RestoreInteractive.config
// fix network/proxy, then retry connector.RestoreDotnetInteractive();
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight the environment before restoring
if (Run("dotnet --version") is null) throw new InvalidOperationException("dotnet CLI not on PATH");
if (!Directory.Exists(connectorInstallDir)) Directory.CreateDirectory(connectorInstallDir);

Try / catch

try { connector.RestoreDotnetInteractive(); }
catch (ArgumentException e) when (e.Message == "Failed to restore dotnet interactive tool.")
{ /* run 'dotnet tool restore' manually in the install dir to see the error; fix network/proxy; retry */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/1be60b2b8a2c7698. Report an issue: GitHub.