Merge pull request #14000 from spowelljr/macPathing

GUI: Add `/usr/local/bin` to `PATH` env on Mac
pull/14008/head
Steven Powell 2022-04-21 13:17:51 -07:00 committed by GitHub
commit 57ecdfd1f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -82,6 +82,7 @@
#include <QDir>
#include <QFontDialog>
#include <QStackedWidget>
#include <QProcessEnvironment>
#ifndef QT_NO_TERMWIDGET
#include <QApplication>
@ -116,6 +117,14 @@ Window::Window()
setWindowIcon(*trayIconIcon);
}
QProcessEnvironment Window::setMacEnv()
{
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString path = env.value("PATH");
env.insert("PATH", path + ":/usr/local/bin");
return env;
}
void Window::createBasicView()
{
basicStartButton = new QPushButton(tr("Start"));
@ -523,6 +532,12 @@ bool Window::sendMinikubeCommand(QStringList cmds, QString &text)
arguments << cmds;
QProcess *process = new QProcess(this);
#if __APPLE__
if (env.isEmpty()) {
env = setMacEnv();
}
process->setProcessEnvironment(env);
#endif
process->start(program, arguments);
this->setCursor(Qt::WaitCursor);
bool timedOut = process->waitForFinished(300 * 1000);

View File

@ -57,6 +57,7 @@
#include <QSystemTrayIcon>
#include <QFormLayout>
#include <QStackedWidget>
#include <QProcessEnvironment>
#ifndef QT_NO_SYSTEMTRAYICON
@ -166,12 +167,14 @@ private:
void dashboardBrowser();
Cluster createClusterObject(QJsonObject obj);
QProcess *dashboardProcess;
QProcessEnvironment env;
// Error messaging
void outputFailedStart(QString text);
QLabel *createLabel(QString title, QString text, QFormLayout *form, bool isLink);
void checkForMinikube();
QProcessEnvironment setMacEnv();
QStackedWidget *stackedWidget;
bool isBasicView;
};