microsoft/autogen · error · ArgumentException

Installing directory is not set

Error message

Installing directory is not set

What it means

Thrown by InteractiveService.RestoreDotnetInteractive when installingDirectory is null. The directory constructor sets it, but the Kernel-based constructor does not; calling RestoreDotnetInteractive on a service built around an already-running kernel has nowhere to install files and throws ArgumentException.

Source

Thrown at dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs:84

    }

    public async Task<string?> SubmitPowershellCodeAsync(string code, CancellationToken ct)
    {
        var command = new SubmitCode(code, targetKernelName: "pwsh");
        return await this.SubmitCommandAsync(command, ct);
    }

    public async Task<string?> SubmitCSharpCodeAsync(string code, CancellationToken ct)
    {
        var command = new SubmitCode(code, targetKernelName: "csharp");
        return await this.SubmitCommandAsync(command, ct);
    }

    public bool RestoreDotnetInteractive()
    {
        if (this.installingDirectory is null)
        {
            throw new ArgumentException("Installing directory is not set");
        }

        // write RestoreInteractive.config from embedded resource to this.workingDirectory
        var assembly = Assembly.GetAssembly(typeof(InteractiveService))!;
        var resourceName = "AutoGen.DotnetInteractive.RestoreInteractive.config";
        using (var stream = assembly.GetManifestResourceStream(resourceName)!)
        using (var fileStream = File.Create(Path.Combine(this.installingDirectory, "RestoreInteractive.config")))
        {
            stream.CopyTo(fileStream);
        }

        // write dotnet-tool.json from embedded resource to this.workingDirectory

        resourceName = "AutoGen.DotnetInteractive.dotnet-tools.json";
        using (var stream2 = assembly.GetManifestResourceStream(resourceName)!)
        using (var fileStream2 = File.Create(Path.Combine(this.installingDirectory, "dotnet-tools.json")))
        {
            stream2.CopyTo(fileStream2);

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Only call RestoreDotnetInteractive on services created with the installingDirectory constructor
  2. If you already have a running kernel, skip restore entirely — it is only needed to install the tool
  3. Create a separate InteractiveService(installingDirectory) instance if some code path must perform a restore

Example fix

// before:
var service = new InteractiveService(existingKernel);
service.RestoreDotnetInteractive(); // throws
// after: don't restore when a kernel already runs
var service = new InteractiveService(existingKernel);
// just use service.SubmitCSharpCodeAsync(...); no restore needed
Defensive patterns

Strategy: type-guard

Validate before calling

// Only restore when the service owns an install directory; expose this via your own wrapper
// InteractiveService exposes Kernel; if Kernel came from outside AND restore is attempted, guard:
if (service.Kernel is not null) { /* kernel already running; skip RestoreDotnetInteractive */ }

Type guard

static bool CanRestore(InteractiveService s) => s.Kernel is null; // directory-ctor implies kernel null initially
// (heuristic: kernel-provided instances must not restore)

Try / catch

try { service.RestoreDotnetInteractive(); }
catch (ArgumentException e) when (e.Message == "Installing directory is not set")
{ /* skip restore; this instance was built around an existing kernel */ }

Prevention

When it happens

Trigger: Constructing InteractiveService with the InteractiveService(Kernel) overload, then calling RestoreDotnetInteractive() (directly or via DotnetInteractiveStdioKernelConnector plumbing) — installingDirectory is null so the guard fires.

Common situations: Sharing a pre-existing kernel across components where one component still tries the install/restore flow, or copy-pasting startup code that mixes both construction styles.

Related errors


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