diff --git a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java index d81611f15..00cf0f582 100644 --- a/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java +++ b/bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java @@ -10,6 +10,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.regex.Matcher; @@ -993,4 +994,29 @@ public static String runEspDetectConfigScript() return null; } } + + /** + * Remove the variables which can affect the idf_tools.py export command + * These variables can come from system environment + * @param environment + */ + public static void cleanUpSystemEnvironment(Map environment) + { + List keysToRenmove = new LinkedList<>(); + keysToRenmove.add(IDFEnvironmentVariables.IDF_PYTHON_ENV_PATH); + keysToRenmove.add(IDFEnvironmentVariables.IDF_PATH); + keysToRenmove.add(IDFEnvironmentVariables.ESP_IDF_VERSION); + keysToRenmove.add(IDFEnvironmentVariables.IDF_CCACHE_ENABLE); + keysToRenmove.add(IDFEnvironmentVariables.IDF_COMPONENT_MANAGER); + keysToRenmove.add(IDFEnvironmentVariables.IDF_MAINTAINER); + keysToRenmove.add(IDFEnvironmentVariables.OPENOCD_SCRIPTS); + + for (String key : keysToRenmove) + { + if (environment.containsKey(key)) + { + environment.remove(key); + } + } + } } diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java index 5fec36a23..1143b2d6b 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java @@ -471,6 +471,7 @@ protected IStatus runCommand(List arguments, MessageConsoleStream consol Logger.log(cmdMsg); Map environment = new HashMap<>(IDFUtil.getSystemEnv()); + Logger.log("Environment Variables from System:"); Logger.log(environment.toString()); environment.put("PYTHONUNBUFFERED", "1"); //$NON-NLS-1$ //$NON-NLS-2$ environment.put("IDF_GITHUB_ASSETS", //$NON-NLS-1$ @@ -487,6 +488,11 @@ protected IStatus runCommand(List arguments, MessageConsoleStream consol { addPathToEnvironmentPath(environment, gitExecutablePath); } + + Logger.log("Environment Variables after filtering from system:"); + IDFUtil.cleanUpSystemEnvironment(environment); + Logger.log(environment.toString()); + Process process = processRunner.run(arguments, org.eclipse.core.runtime.Path.ROOT, environment); IStatus status = processData(process); console.println(); diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/ExportIDFTools.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/ExportIDFTools.java index 6a6b6a6eb..bede42343 100644 --- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/ExportIDFTools.java +++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/ExportIDFTools.java @@ -132,6 +132,8 @@ public IStatus getToolsExportOutputFromGivenIdfPath(final String pythonExePath, addGitToEnvironment(environment, gitExePath); } + IDFUtil.cleanUpSystemEnvironment(environment); + final ProcessBuilderFactory processRunner = new ProcessBuilderFactory(); try {