{"record":{"id":"6f201722a595617e","repo":"microsoft/aspire","slug":"unable-to-determine-current-cli-location","errorCode":null,"errorMessage":"Unable to determine current CLI location.","messagePattern":"Unable to determine current CLI location\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Commands/UpdateCommand.cs","lineNumber":755,"sourceCode":"            return CommandResult.Cancelled();\n        }\n        catch (Exception ex)\n        {\n            Telemetry.RecordError(\"Failed to update CLI\", ex);\n            var errorMessage = $\"Failed to update CLI: {ex.Message}\";\n            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 () =>","sourceCodeStart":737,"sourceCodeEnd":773,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Commands/UpdateCommand.cs#L737-L773","documentation":"Thrown when constructing/executing the archive-based self-update path and `Environment.ProcessPath` (provided by the process path provider) is null or empty, so the CLI cannot locate its own executable to replace in place. Without the current executable path a same-directory replacement is impossible, so the update aborts with an InvalidOperationException.","triggerScenarios":"Running `aspire update --self` in an environment where the process path cannot be determined — e.g. exotic hosts, embedded/redirected launches, or wrapper processes that do not expose the real executable path.","commonSituations":"Running the CLI through unusual launchers, sandboxed environments that hide the executable path, or custom builds where the process path provider is stubbed.","solutions":["Run the official `aspire` executable directly rather than through a wrapper script or launcher","Upgrade the CLI using the platform installer instead of `--self` archive update","Check that Environment.ProcessPath is non-empty in your host environment; report a CLI bug if it is empty in a normal launch"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var exePath = Environment.ProcessPath;\nif (string.IsNullOrEmpty(exePath))\n    Console.Error.WriteLine(\"Cannot self-update: process path unavailable; use the installer instead.\");","typeGuard":"bool canSelfUpdate => !string.IsNullOrEmpty(Environment.ProcessPath);","tryCatchPattern":"try { await UpdateSelfAsync(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Unable to determine current CLI location\"))\n{ Console.Error.WriteLine(\"Use the platform installer script instead of --self.\"); }","preventionTips":["Launch the official aspire binary directly, not via wrappers","Prefer installer-script updates in sandboxed/containerized environments"],"tags":["cli","self-update","filesystem"],"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"}