From 3d4729b7afacef214e3009d3ce72b109b88b6adb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Jun 2026 13:56:38 +0000 Subject: [PATCH 1/2] Initial plan From 564e8448a57282792ab88799ae06b21790d3dc8d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Jun 2026 14:03:29 +0000 Subject: [PATCH 2/2] Fix update command incorrectly reporting "already at latest version" The update command now checks for available updates BEFORE running the update process, stores the expected new version, and reports that version after successful update. This fixes the issue where running "cratis update" would always show "Already at the latest version" even when an update was available, because the currently running process version cannot change until the CLI is restarted. Also added user guidance that the new version will be active when they run 'cratis' again. --- .../Cli/Commands/Version/SelfUpdateCommand.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Source/Cli/Commands/Version/SelfUpdateCommand.cs b/Source/Cli/Commands/Version/SelfUpdateCommand.cs index c6543df..dd3bc8c 100644 --- a/Source/Cli/Commands/Version/SelfUpdateCommand.cs +++ b/Source/Cli/Commands/Version/SelfUpdateCommand.cs @@ -23,6 +23,21 @@ protected override async Task ExecuteAsync(CommandContext context, SelfUpda var currentVersion = VersionCommand.GetCliVersion(); var strategy = CliUpdate.DetectStrategy(); + // Check for available updates before performing the update + var expectedNewVersion = settings.TargetVersion; + if (string.IsNullOrWhiteSpace(expectedNewVersion)) + { + using var updateCheckCts = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + try + { + expectedNewVersion = await UpdateChecker.CheckForUpdate(UpdateChecker.CliPackageId, currentVersion, updateCheckCts.Token); + } + catch + { + // If we can't check for updates, proceed anyway - the update tool will handle it + } + } + if (string.Equals(format, OutputFormats.Table, StringComparison.Ordinal)) { AnsiConsole.MarkupLine($"[bold]Updating Cratis CLI...[/] (current: {currentVersion.EscapeMarkup()})"); @@ -72,7 +87,10 @@ protected override async Task ExecuteAsync(CommandContext context, SelfUpda return updateResult.Value; } - var newVersion = VersionCommand.GetCliVersion(); + // Use the expected new version instead of checking the currently running assembly + // The currently running process won't change version until it's restarted + var newVersion = expectedNewVersion ?? currentVersion; + var wasUpdated = !string.IsNullOrWhiteSpace(expectedNewVersion); if (string.Equals(format, OutputFormats.Json, StringComparison.Ordinal) || string.Equals(format, OutputFormats.JsonCompact, StringComparison.Ordinal)) { @@ -80,12 +98,13 @@ protected override async Task ExecuteAsync(CommandContext context, SelfUpda { PreviousVersion = currentVersion, CurrentVersion = newVersion, - Updated = currentVersion != newVersion + Updated = wasUpdated }); } - else if (currentVersion != newVersion) + else if (wasUpdated) { AnsiConsole.MarkupLine($"[green]Updated from {currentVersion.EscapeMarkup()} to {newVersion.EscapeMarkup()}[/]"); + AnsiConsole.MarkupLine("[dim]The new version will be active when you run 'cratis' again.[/]"); } else {