From a7b46ca32dee357ed205a8721d82845c0549a0c3 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Wed, 12 Aug 2026 16:48:53 -0700 Subject: [PATCH] Improve missing Podman error message Show actionable installation guidance when podman.exe cannot be launched and cover the behavior with a regression test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d7a53406-d577-464e-a293-0ced3385ee6f --- src/SSHDebugPS/Podman/PodmanHelper.cs | 25 +++++++++++++++-------- src/SSHDebugPS/UI/UIResources.Designer.cs | 9 ++++++++ src/SSHDebugPS/UI/UIResources.resx | 4 ++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/SSHDebugPS/Podman/PodmanHelper.cs b/src/SSHDebugPS/Podman/PodmanHelper.cs index 5d25de158..d81ee780c 100644 --- a/src/SSHDebugPS/Podman/PodmanHelper.cs +++ b/src/SSHDebugPS/Podman/PodmanHelper.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Text; @@ -17,7 +18,7 @@ public class PodmanHelper { private const string podmanPSCommand = "ps"; private const string podmanPSArgs = "-f status=running --no-trunc --format \"{{json .}}\""; - + private const int win32ErrorFileNotFound = 2; internal static IEnumerable GetLocalPodmanContainers(string hostname, out int totalContainers) { @@ -28,17 +29,25 @@ internal static IEnumerable GetLocalPodmanContainers(st PodmanCommandSettings settings = new PodmanCommandSettings(hostname, false); settings.SetCommand(podmanPSCommand, podmanPSArgs); - DockerHelper.RunContainerCommand(settings, delegate (string args) + try { - if (args.Trim()[0] == '{') + DockerHelper.RunContainerCommand(settings, delegate (string args) { - if (PodmanContainerInstance.TryCreate(args, out PodmanContainerInstance containerInstance)) + if (args.Trim()[0] == '{') { - containers.Add(containerInstance); + if (PodmanContainerInstance.TryCreate(args, out PodmanContainerInstance containerInstance)) + { + containers.Add(containerInstance); + } + containerCount++; } - containerCount++; - } - }); + }); + } + catch (CommandFailedException ex) when (ex.InnerException is Win32Exception win32Exception && + win32Exception.NativeErrorCode == win32ErrorFileNotFound) + { + throw new CommandFailedException(UIResources.PodmanExecutableNotFound, ex); + } totalContainers = containerCount; return containers; diff --git a/src/SSHDebugPS/UI/UIResources.Designer.cs b/src/SSHDebugPS/UI/UIResources.Designer.cs index fce792a7a..64b0b08a0 100644 --- a/src/SSHDebugPS/UI/UIResources.Designer.cs +++ b/src/SSHDebugPS/UI/UIResources.Designer.cs @@ -302,6 +302,15 @@ public static string Podman_ConnectionToolTip { return ResourceManager.GetString("Podman_ConnectionToolTip", resourceCulture); } } + + /// + /// Looks up a localized string similar to Podman was not found. Install Podman, ensure podman.exe is available on PATH, and restart Visual Studio.. + /// + public static string PodmanExecutableNotFound { + get { + return ResourceManager.GetString("PodmanExecutableNotFound", resourceCulture); + } + } /// /// Looks up a localized string similar to Optional Podman Host name. diff --git a/src/SSHDebugPS/UI/UIResources.resx b/src/SSHDebugPS/UI/UIResources.resx index e06689608..7c7d7e5e5 100644 --- a/src/SSHDebugPS/UI/UIResources.resx +++ b/src/SSHDebugPS/UI/UIResources.resx @@ -252,6 +252,10 @@ Location from which to run the Podman CLI. To manage remote connections, in the menu go to Tools -> Options and find Cross Platform -> Connection Manager. + + Podman was not found. Install Podman, ensure podman.exe is available on PATH, and restart Visual Studio. + {Locked="Podman"} {Locked="podman.exe"} {Locked="PATH"} {Locked="Visual Studio"} + Optional Podman Host name