Skip to content

Commit d407f79

Browse files
committed
InstallWizard: fix brew detection on Apple Silicon, resolve brew path directly
1 parent fd5affd commit d407f79

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

mode/CppMode.jar

57 Bytes
Binary file not shown.

src/java/InstallWizard.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,13 @@ private boolean runMac(java.util.List<String> missing) {
456456
return;
457457
}
458458

459-
if (!commandExists("brew", "--version")) {
459+
// Check for brew at known locations -- Processing may launch without
460+
// /opt/homebrew/bin in PATH on Apple Silicon Macs.
461+
String brewExe = null;
462+
if (new File("/opt/homebrew/bin/brew").exists()) brewExe = "/opt/homebrew/bin/brew";
463+
else if (new File("/usr/local/bin/brew").exists()) brewExe = "/usr/local/bin/brew";
464+
else if (commandExists("brew", "--version")) brewExe = "brew";
465+
if (brewExe == null) {
460466
setStep("Installing Homebrew...");
461467
appendLog("Homebrew not found — installing it now.");
462468
appendLog("This downloads and runs the official Homebrew installer.");
@@ -488,21 +494,24 @@ private boolean runMac(java.util.List<String> missing) {
488494
finishDialog(false, "Couldn't install Homebrew — see log above.");
489495
return;
490496
}
491-
// Verify brew is now available
492-
if (!commandExists("brew", "--version")) {
497+
// Verify brew is now available after install
498+
if (!new File("/opt/homebrew/bin/brew").exists()
499+
&& !new File("/usr/local/bin/brew").exists()
500+
&& !commandExists("brew", "--version")) {
493501
finishDialog(false,
494502
"Homebrew was installed but couldn't be found. Please restart Processing and try again.");
495503
return;
496504
}
505+
// Re-resolve brewExe after install
506+
if (new File("/opt/homebrew/bin/brew").exists()) brewExe = "/opt/homebrew/bin/brew";
507+
else if (new File("/usr/local/bin/brew").exists()) brewExe = "/usr/local/bin/brew";
497508
}
498509

499510
setStep("Installing: " + String.join(", ", missingLibs));
500511
try {
501512
java.util.List<String> brewCmd = new java.util.ArrayList<>();
502513
// Resolve brew path explicitly for Apple Silicon
503-
String brewBin = new File("/opt/homebrew/bin/brew").exists()
504-
? "/opt/homebrew/bin/brew" : "brew";
505-
brewCmd.add(brewBin); brewCmd.add("install");
514+
brewCmd.add(brewExe); brewCmd.add("install");
506515
brewCmd.addAll(missingLibs);
507516
ProcessBuilder brewPb = new ProcessBuilder(brewCmd);
508517
String brewPath = System.getenv("PATH");

0 commit comments

Comments
 (0)