diff --git a/src/main/java/com/ajinkyagokhale/espflasher/service/PrereqChecker.java b/src/main/java/com/ajinkyagokhale/espflasher/service/PrereqChecker.java index c07b879..d1edf7d 100644 --- a/src/main/java/com/ajinkyagokhale/espflasher/service/PrereqChecker.java +++ b/src/main/java/com/ajinkyagokhale/espflasher/service/PrereqChecker.java @@ -173,7 +173,18 @@ public boolean installEsptool(Consumer onLine) { } } p.waitFor(); + + // After pip installs a new package, the shell may cache "command not found". + // Brief pause + retry ensures the newly installed esptool is discoverable. checkAll(); + if (esptoolCmd == null) { + try { + Thread.sleep(500); + } catch (InterruptedException ignored) { + Thread.currentThread().interrupt(); + } + checkAll(); + } return esptoolCmd != null; } catch (IOException | InterruptedException e) { Thread.currentThread().interrupt(); diff --git a/src/main/java/com/ajinkyagokhale/espflasher/ui/FlasherApp.java b/src/main/java/com/ajinkyagokhale/espflasher/ui/FlasherApp.java index 73d09d9..ac0c4f8 100644 --- a/src/main/java/com/ajinkyagokhale/espflasher/ui/FlasherApp.java +++ b/src/main/java/com/ajinkyagokhale/espflasher/ui/FlasherApp.java @@ -1067,30 +1067,26 @@ private Map> groupByCategory() { private void checkPrerequisites() { statusLabel.setText("Checking prerequisites..."); + // Run check in background, then update UI once result is known Thread thread = new Thread(() -> { prereqChecker.checkAll(); Platform.runLater(() -> { if (prereqChecker.isReady()) { statusLabel.setText("Ready."); + } else if (prereqChecker.getPythonCmd() == null) { + showPythonMissingDialog(); } else { + // Python exists but esptool doesn't — offer to install statusLabel.setText("esptool not found — click here to install."); statusLabel.setStyle("-fx-text-fill: #2196f3; -fx-underline: true; -fx-cursor: hand;"); statusLabel.setOnMouseClicked(e -> installEsptool()); + // Auto-trigger install dialog on first run + autoInstallEsptool(); } }); }); thread.setDaemon(true); thread.start(); - - Platform.runLater(() -> { - if (prereqChecker.isReady()) { - statusLabel.setText("Ready."); - } else if (prereqChecker.getPythonCmd() == null) { - showPythonMissingDialog(); - } else { - autoInstallEsptool(); - } - }); } private void installEsptool() {