From 40612bceeed36cb688b699a7531dbc65fd5bdd6a Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 14 Nov 2019 14:22:28 +0100 Subject: [PATCH] Python: Fix python run configuration Add the WorkingDirectoryAspect to prevent running the main script in an unpredictable location. Change-Id: I1be206261b7983e933b53ccd57c93089154d8417 Reviewed-by: Eike Ziller Reviewed-by: Cristian Maureira-Fredes --- src/plugins/python/pythonrunconfiguration.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index d6bc6061e10..047d15e6ef1 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -274,6 +274,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Core::Id id) auto argumentsAspect = addAspect(); + addAspect(); addAspect(); setCommandLineGetter([this, interpreterAspect, argumentsAspect] { @@ -305,6 +306,9 @@ void PythonRunConfiguration::updateLanguageServer() PyLSConfigureAssistant::instance()->openDocumentWithPython(python, document); } } + + aspect()->setDefaultWorkingDirectory( + Utils::FilePath::fromString(mainScript()).parentDir()); } bool PythonRunConfiguration::supportsDebugger() const