diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index dc94c31415b..d84037ec4e5 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -259,6 +259,12 @@ void QtcProcess::setEnvironment(const Environment &env) d->m_haveEnv = true; } +void QtcProcess::unsetEnvironment() +{ + d->m_environment = Environment(); + d->m_haveEnv = false; +} + const Environment &QtcProcess::environment() const { return d->m_environment; diff --git a/src/libs/utils/qtcprocess.h b/src/libs/utils/qtcprocess.h index 95fe4d22563..7cf21f4659b 100644 --- a/src/libs/utils/qtcprocess.h +++ b/src/libs/utils/qtcprocess.h @@ -80,6 +80,7 @@ public: }; void setEnvironment(const Environment &env); + void unsetEnvironment(); const Environment &environment() const; void setCommand(const CommandLine &cmdLine); diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index bacbc36204c..3d8b4f40547 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -1396,12 +1396,24 @@ void DockerDevice::runProcess(QtcProcess &process) const const FilePath workingDir = process.workingDirectory(); const CommandLine origCmd = process.commandLine(); + const Environment env = process.environment(); CommandLine cmd{"docker", {"exec"}}; if (!workingDir.isEmpty()) cmd.addArgs({"-w", workingDir.path()}); if (process.keepsWriteChannelOpen()) cmd.addArg("-i"); + if (env.size() != 0 && d->m_accessible != DockerDevicePrivate::Accessible) { + process.unsetEnvironment(); + // FIXME the below would be probably correct if the respective tools would use correct + // environment already, but most are using the host environment which usually makes + // no sense on the device and may degrade performance + // const QStringList envList = env.toStringList(); + // for (const QString &keyValue : envList) { + // cmd.addArg("-e"); + // cmd.addArg(keyValue); + // } + } cmd.addArg(d->m_container); cmd.addArg(origCmd.executable().path()); // Cut off the docker://.../ bits. cmd.addArgs(origCmd.splitArguments(osType()));