{"record":{"id":"60f33bb308fd3ac1","repo":"microsoft/aspire","slug":"unable-to-determine-installation-directory-from","errorCode":null,"errorMessage":"Unable to determine installation directory from: {currentExePath}","messagePattern":"Unable to determine installation directory from: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Commands/UpdateCommand.cs","lineNumber":761,"sourceCode":"            return CommandResult.Failure(CliExitCodes.InvalidCommand, errorMessage);\n        }\n    }\n\n    private async Task ExtractAndUpdateAsync(string archivePath, string channel, CancellationToken cancellationToken)\n    {\n        // Archive self-update is a same-directory replacement, not an installer that searches\n        // for a writable fallback. If the executable is package-manager-owned, installing\n        // elsewhere would leave the user's PATH/profile pointing at the old package-managed CLI.\n        var currentExePath = _processPathProvider.ProcessPath;\n        if (string.IsNullOrEmpty(currentExePath))\n        {\n            throw new InvalidOperationException(\"Unable to determine current CLI location.\");\n        }\n\n        var installDir = Path.GetDirectoryName(currentExePath);\n        if (string.IsNullOrEmpty(installDir))\n        {\n            throw new InvalidOperationException($\"Unable to determine installation directory from: {currentExePath}\");\n        }\n\n        var exeName = _environment.IsWindows() ? \"aspire.exe\" : \"aspire\";\n        var targetExePath = Path.Combine(installDir, exeName);\n        var tempExtractDir = Directory.CreateTempSubdirectory(\"aspire-cli-extract\").FullName;\n\n        try\n        {\n            // Extract archive\n            await InteractionService.ShowStatusAsync(\n                UpdateCommandStrings.ExtractingNewCli,\n                async () =>\n                {\n                    await ArchiveHelper.ExtractAsync(archivePath, tempExtractDir, _environment, cancellationToken);\n                    return 0;\n                },\n                KnownEmojis.Package);\n","sourceCodeStart":743,"sourceCodeEnd":779,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Commands/UpdateCommand.cs#L743-L779","documentation":"A follow-up failure in the archive self-update path: the executable path was known but `Path.GetDirectoryName` returned null or empty, meaning the executable path had no directory component (e.g. a bare name or rootless path). The CLI cannot compute the installation directory to replace the binary in, so it throws.","triggerScenarios":"`aspire update --self` when the current executable path is malformed or relative without a directory, or the process path provider returns a value like just 'aspire' without any path separator.","commonSituations":"Custom process-path provider stubs in tests, exotic sandboxes reporting abbreviated executable paths, or corrupted launch environments.","solutions":["Ensure the CLI is launched via its full absolute path (e.g. /usr/local/bin/aspire)","Reinstall the CLI with the official installer so the executable lives at a normal absolute path","Avoid stubbing or overriding the process path provider in ways that return directory-less paths"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var exePath = Environment.ProcessPath;\nif (string.IsNullOrEmpty(Path.GetDirectoryName(exePath)))\n    Console.Error.WriteLine($\"Executable path '{exePath}' has no directory component; self-update unsupported.\");","typeGuard":"bool hasInstallDir => Path.GetDirectoryName(Environment.ProcessPath) is { Length: > 0 };","tryCatchPattern":"try { await UpdateSelfAsync(); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Unable to determine installation directory\"))\n{ Console.Error.WriteLine(\"Reinstall the CLI at a normal absolute path.\"); }","preventionTips":["Always execute the CLI via its absolute path","Reinstall with the official installer if the binary lives at an unusual path"],"tags":["cli","self-update","path"],"backgroundTag":"internal-invariant-violation","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}