From 55916df97dd682adcc9d573ed09a0589aa5ee3cd Mon Sep 17 00:00:00 2001 From: Yez Ezey Date: Mon, 7 Nov 2016 13:29:55 +0900 Subject: [PATCH] Set /usr/local/bin before default PATH on macOS. closes #5639 #5571 Since Apple made difficult for users to set PATH and /usr/bin/python is almost unusable, I simply add /usr/local/bin before default PATH to pick up Homebrew Python. --- src/app/main.cpp | 11 +++++++++++ src/gui/mainwindow.cpp | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index f4848f408..6171f99d7 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -230,6 +230,17 @@ int main(int argc, char *argv[]) qputenv("QT_BEARER_POLL_TIMEOUT", QByteArray::number(-1)); #endif +#if defined(Q_OS_MAC) +{ + // Since Apple made difficult for users to set PATH, we set here for convenience. + // Users are supposed to install Homebrew Python for search function. + // For more info see issue #5571. + QByteArray path = "/usr/local/bin:"; + path += qgetenv("PATH"); + qputenv("PATH", path.constData()); +} +#endif + #ifndef DISABLE_GUI if (!upgrade()) return EXIT_FAILURE; #else diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index f1020eee7..044261e9e 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1476,7 +1476,8 @@ void MainWindow::on_actionSearchWidget_triggered() // Check if python is already in PATH if (pythonVersion > 0) - Logger::instance()->addMessage(tr("Python found in %1").arg("PATH"), Log::INFO); // Prevent translators from messing with PATH + // Prevent translators from messing with PATH + Logger::instance()->addMessage(tr("Python found in %1: %2", "Python found in PATH: /usr/local/bin:/usr/bin:/etc/bin").arg("PATH").arg(qgetenv("PATH").constData()), Log::INFO); #ifdef Q_OS_WIN else if (addPythonPathToEnv()) pythonVersion = Utils::Misc::pythonVersion();