Skip to content
Permalink
Browse files
Append current typesetting tool's path to $PATH on Mac OS X (fixes #861
…, fixes #897)

This way, programs in the same directory as the typesetting tool can be
found, even though .bash_profile etc. are not parsed when running
TeXworks from the Finder.
  • Loading branch information
stloeffler committed May 27, 2020
1 parent a819f9f commit f607e719625512e8940a97caf6e6dc3258763a0b
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/Engine.cpp
@@ -131,6 +131,22 @@ QProcess * Engine::run(const QFileInfo & input, QObject * parent /* = nullptr */
env.insert(QStringLiteral("MIKTEX_EDITOR"), QStringLiteral("%1 --position=%l \"%f\"").arg(QCoreApplication::applicationFilePath()));
#endif

#if defined(Q_OS_DARWIN)
// On Mac OS X, append the path to the typesetting tool to the PATH
// environment variable.
// In recent versions of Mac OS X and Qt, GUI applications (like Tw) get
// different values for PATH than console applications (because .bashrc etc.
// don't get parsed). Typesetting tools still run correctly (as they are
// invoked with a full path), but if they in turn try to run other tools
// (like epstopdf) without full path, the process will fail.
// Appending the path to the typesetting tool to PATH acts as a fallback and
// implicitly assumes that the tool itself and all tools it relies on are in
// the same (standard) location.
QStringList envPaths = env.value(QStringLiteral("PATH")).split(QStringLiteral(PATH_LIST_SEP));
envPaths.append(QFileInfo(exeFilePath).dir().absolutePath());
env.insert(QStringLiteral("PATH"), envPaths.join(QStringLiteral(PATH_LIST_SEP)));
#endif

QStringList args = arguments();

// for old MikTeX versions: delete $synctexoption if it causes an error

0 comments on commit f607e71

Please sign in to comment.