Skip to content

Commit

Permalink
Add brew to the path in order to find qemu
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed Feb 27, 2022
1 parent cf85025 commit bd0ae7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lima.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lima.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
extern QString defaultYAML();
extern QString defaultURL();

extern QStringList brewPaths();
extern QString limactlPath();

#endif // LIMA_H
6 changes: 6 additions & 0 deletions window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit bd0ae7a

Please sign in to comment.