{"record":{"id":"6917bd9158da63a8","repo":"microsoft/autogen","slug":"installing-directory-is-not-set","errorCode":null,"errorMessage":"Installing directory is not set","messagePattern":"Installing directory is not set","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs","lineNumber":84,"sourceCode":"    }\n\n    public async Task<string?> SubmitPowershellCodeAsync(string code, CancellationToken ct)\n    {\n        var command = new SubmitCode(code, targetKernelName: \"pwsh\");\n        return await this.SubmitCommandAsync(command, ct);\n    }\n\n    public async Task<string?> SubmitCSharpCodeAsync(string code, CancellationToken ct)\n    {\n        var command = new SubmitCode(code, targetKernelName: \"csharp\");\n        return await this.SubmitCommandAsync(command, ct);\n    }\n\n    public bool RestoreDotnetInteractive()\n    {\n        if (this.installingDirectory is null)\n        {\n            throw new ArgumentException(\"Installing directory is not set\");\n        }\n\n        // write RestoreInteractive.config from embedded resource to this.workingDirectory\n        var assembly = Assembly.GetAssembly(typeof(InteractiveService))!;\n        var resourceName = \"AutoGen.DotnetInteractive.RestoreInteractive.config\";\n        using (var stream = assembly.GetManifestResourceStream(resourceName)!)\n        using (var fileStream = File.Create(Path.Combine(this.installingDirectory, \"RestoreInteractive.config\")))\n        {\n            stream.CopyTo(fileStream);\n        }\n\n        // write dotnet-tool.json from embedded resource to this.workingDirectory\n\n        resourceName = \"AutoGen.DotnetInteractive.dotnet-tools.json\";\n        using (var stream2 = assembly.GetManifestResourceStream(resourceName)!)\n        using (var fileStream2 = File.Create(Path.Combine(this.installingDirectory, \"dotnet-tools.json\")))\n        {\n            stream2.CopyTo(fileStream2);","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.DotnetInteractive/InteractiveService.cs#L66-L102","documentation":"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.","triggerScenarios":"Constructing InteractiveService with the InteractiveService(Kernel) overload, then calling RestoreDotnetInteractive() (directly or via DotnetInteractiveStdioKernelConnector plumbing) — installingDirectory is null so the guard fires.","commonSituations":"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.","solutions":["Only call RestoreDotnetInteractive on services created with the installingDirectory constructor","If you already have a running kernel, skip restore entirely — it is only needed to install the tool","Create a separate InteractiveService(installingDirectory) instance if some code path must perform a restore"],"exampleFix":"// before:\nvar service = new InteractiveService(existingKernel);\nservice.RestoreDotnetInteractive(); // throws\n// after: don't restore when a kernel already runs\nvar service = new InteractiveService(existingKernel);\n// just use service.SubmitCSharpCodeAsync(...); no restore needed","handlingStrategy":"type-guard","validationCode":"// Only restore when the service owns an install directory; expose this via your own wrapper\n// InteractiveService exposes Kernel; if Kernel came from outside AND restore is attempted, guard:\nif (service.Kernel is not null) { /* kernel already running; skip RestoreDotnetInteractive */ }","typeGuard":"static bool CanRestore(InteractiveService s) => s.Kernel is null; // directory-ctor implies kernel null initially\n// (heuristic: kernel-provided instances must not restore)","tryCatchPattern":"try { service.RestoreDotnetInteractive(); }\ncatch (ArgumentException e) when (e.Message == \"Installing directory is not set\")\n{ /* skip restore; this instance was built around an existing kernel */ }","preventionTips":["Never call RestoreDotnetInteractive on a Kernel-constructed service","Confine restore calls to the component that created the service with a directory"],"tags":["autogen","dotnet-interactive","lifecycle","misuse"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}