diff --git a/lima.cpp b/lima.cpp index 02485c3..c14d0c8 100644 --- a/lima.cpp +++ b/lima.cpp @@ -16,12 +16,16 @@ QString defaultURL() return "https://github.com/lima-vm/lima/blob/master/examples/default.yaml"; } +QStringList brewPaths() +{ + return QStringList({ "/usr/local/bin", "/opt/homebrew/bin", "/home/linuxbrew/.linuxbrew/bin" }); +} + QString limactlPath() { QString program = QStandardPaths::findExecutable("limactl"); if (program.isEmpty()) { - QStringList paths = { "/usr/local/bin", "/opt/homebrew/bin", - "/home/linuxbrew/.linuxbrew/bin" }; + QStringList paths = brewPaths(); program = QStandardPaths::findExecutable("limactl", paths); } return program; diff --git a/lima.h b/lima.h index 97c28f4..8bccd6a 100644 --- a/lima.h +++ b/lima.h @@ -4,6 +4,7 @@ extern QString defaultYAML(); extern QString defaultURL(); +extern QStringList brewPaths(); extern QString limactlPath(); #endif // LIMA_H diff --git a/window.cpp b/window.cpp index 5dfd7c0..1aeaf46 100644 --- a/window.cpp +++ b/window.cpp @@ -706,6 +706,12 @@ void Window::sendCommand(QStringList arguments) { QString program = limactlPath(); process = new QProcess(this); +#ifdef Q_OS_OSX + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + // the macOS PATH does not inherit from the terminal PATH, add brew + env.insert("PATH", brewPaths().join(":") + ":" + env.value("PATH")); + process->setProcessEnvironment(env); +#endif connect(process, SIGNAL(started()), this, SLOT(startedCommand())); connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finishedCommand(int, QProcess::ExitStatus)));