From 529f835c119a7ed582b9f5cafb4899779608a254 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 18 Jun 2025 13:26:15 +0200 Subject: [PATCH] ProjectExplorer: Expand run environment ... before passing it to the process. Fixes: QTCREATORBUG-33095 Change-Id: I2bbe9ed6205ae1a5b58736db86e064d5edc0b8b0 Reviewed-by: hjk --- src/plugins/projectexplorer/environmentaspect.cpp | 9 +++++++++ src/plugins/projectexplorer/environmentaspect.h | 1 + src/plugins/projectexplorer/runconfiguration.cpp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/environmentaspect.cpp b/src/plugins/projectexplorer/environmentaspect.cpp index adaede9ac56..099e1eb35ec 100644 --- a/src/plugins/projectexplorer/environmentaspect.cpp +++ b/src/plugins/projectexplorer/environmentaspect.cpp @@ -77,6 +77,15 @@ Utils::Environment EnvironmentAspect::environment() const return env; } +Environment EnvironmentAspect::expandedEnvironment(const Utils::MacroExpander &expander) const +{ + Environment expandedEnv; + environment().forEachEntry([&](const QString &key, const QString &value, bool) { + expandedEnv.set(key, expander.expand(value)); + }); + return expandedEnv; +} + Environment EnvironmentAspect::modifiedBaseEnvironment() const { QTC_ASSERT(m_base >= 0 && m_base < m_baseEnvironments.size(), return Environment()); diff --git a/src/plugins/projectexplorer/environmentaspect.h b/src/plugins/projectexplorer/environmentaspect.h index 62dd24de276..99c31f5bcba 100644 --- a/src/plugins/projectexplorer/environmentaspect.h +++ b/src/plugins/projectexplorer/environmentaspect.h @@ -25,6 +25,7 @@ public: // The environment including the user's modifications. Utils::Environment environment() const; + Utils::Environment expandedEnvironment(const Utils::MacroExpander &expander) const; // Environment including modifiers, but without explicit user changes. Utils::Environment modifiedBaseEnvironment() const; diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index ad259008f59..64d33e44011 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -503,7 +503,7 @@ ProcessRunData RunConfiguration::runnable() const if (auto workingDirectoryAspect = aspect()) r.workingDirectory = r.command.executable().withNewMappedPath(workingDirectoryAspect->workingDirectory()); if (auto environmentAspect = aspect()) - r.environment = environmentAspect->environment(); + r.environment = environmentAspect->expandedEnvironment(*macroExpander()); if (m_runnableModifier) m_runnableModifier(r);