From 9b20fe7e8e3fdf3781d48f08ce41b1908b66d8bc Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 20 Nov 2024 09:19:24 +0000 Subject: [PATCH] Improve homebrew check --- .../app/core/check/AppHomebrewCoreutilsCheck.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java index 8a8e91b8b..00e505f53 100644 --- a/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java +++ b/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java @@ -2,21 +2,23 @@ package io.xpipe.app.core.check; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.core.process.OsType; +import io.xpipe.core.store.FileNames; +import java.util.Optional; import java.util.concurrent.TimeUnit; public class AppHomebrewCoreutilsCheck { - public static boolean hasCoreutils() { + public static Optional checkCoreutils() { var fc = new ProcessBuilder("which", "stat").redirectErrorStream(true); try { var proc = fc.start(); var out = new String(proc.getInputStream().readAllBytes()); proc.waitFor(1, TimeUnit.SECONDS); var first = out.lines().findFirst(); - return first.map(s -> s.contains("coreutils")).orElse(false); + return first.filter(s -> s.contains("coreutils")).map(s -> FileNames.getParent(s)); } catch (Exception e) { - return false; + return Optional.empty(); } } @@ -25,8 +27,9 @@ public class AppHomebrewCoreutilsCheck { return; } - if (hasCoreutils()) { - ErrorEvent.fromMessage("You have the homebrew coreutils package installed and added to your PATH." + + var loc = checkCoreutils(); + if (loc.isPresent()) { + ErrorEvent.fromMessage("You have the homebrew coreutils package installed and added to your PATH at " + loc.get() + "." + " The coreutils commands overwrite and are incompatible to the native macOS commands, which XPipe expects." + " Please remove the coreutils commands from your PATH prior to launching XPipe.") .term()