From ea86896e9c75701fb679ca2b59ae6ec7e9986d52 Mon Sep 17 00:00:00 2001 From: Ali Azam Rana <85216275+alirana01@users.noreply.github.com> Date: Mon, 8 Sep 2025 15:17:24 +0200 Subject: [PATCH 1/4] IEP-1628: Remove conflicting System env variables for export command --- .../idf/ui/update/ExportIDFTools.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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..3e449c01a 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 @@ -8,6 +8,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -132,6 +133,8 @@ public IStatus getToolsExportOutputFromGivenIdfPath(final String pythonExePath, addGitToEnvironment(environment, gitExePath); } + cleanUpSystemEnvironment(environment); + final ProcessBuilderFactory processRunner = new ProcessBuilderFactory(); try { @@ -157,6 +160,26 @@ public IStatus getToolsExportOutputFromGivenIdfPath(final String pythonExePath, } } + /** + * Remove the variables which can affect the idf_tools.py export command + * These variables can come from system environment + * @param environment + */ + private void cleanUpSystemEnvironment(Map environment) + { + List keysToRenmove = new LinkedList<>(); + keysToRenmove.add(IDFEnvironmentVariables.IDF_PYTHON_ENV_PATH); + keysToRenmove.add(IDFEnvironmentVariables.IDF_PATH); + + for (String key : keysToRenmove) + { + if (environment.containsKey(key)) + { + environment.remove(key); + } + } + } + private List getExportCommandUsingGivenIdfPath(String pythonExePath, String idfPath) { final List arguments = new ArrayList<>(); From 060265c302b583e0a18223610a4bd84c8c582f83 Mon Sep 17 00:00:00 2001 From: Ali Azam Rana <85216275+alirana01@users.noreply.github.com> Date: Tue, 9 Sep 2025 14:46:13 +0200 Subject: [PATCH 2/4] updated keys to remove that can cause possible issues --- .../src/com/espressif/idf/ui/update/ExportIDFTools.java | 5 +++++ 1 file changed, 5 insertions(+) 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 3e449c01a..4bc8530df 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 @@ -170,6 +170,11 @@ private 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) { From 938727bc41f32162103882f1d2c600b1f17f9117 Mon Sep 17 00:00:00 2001 From: Ali Azam Rana <85216275+alirana01@users.noreply.github.com> Date: Mon, 15 Sep 2025 14:30:34 +0200 Subject: [PATCH 3/4] moved function to utility method Moved the cleanup to utility class and also added the cleanup call in required command runs --- .../com/espressif/idf/core/util/IDFUtil.java | 26 +++++++++++++++++ .../com/espressif/idf/ui/tools/ToolsJob.java | 6 ++++ .../idf/ui/update/ExportIDFTools.java | 28 +------------------ 3 files changed, 33 insertions(+), 27 deletions(-) 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..5af4736cd 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); + 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 4bc8530df..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 @@ -8,7 +8,6 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -133,7 +132,7 @@ public IStatus getToolsExportOutputFromGivenIdfPath(final String pythonExePath, addGitToEnvironment(environment, gitExePath); } - cleanUpSystemEnvironment(environment); + IDFUtil.cleanUpSystemEnvironment(environment); final ProcessBuilderFactory processRunner = new ProcessBuilderFactory(); try @@ -160,31 +159,6 @@ public IStatus getToolsExportOutputFromGivenIdfPath(final String pythonExePath, } } - /** - * Remove the variables which can affect the idf_tools.py export command - * These variables can come from system environment - * @param environment - */ - private 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); - } - } - } - private List getExportCommandUsingGivenIdfPath(String pythonExePath, String idfPath) { final List arguments = new ArrayList<>(); From bdd4169aca03c0fd29232dd199854621e9d47b11 Mon Sep 17 00:00:00 2001 From: Ali Azam Rana <85216275+alirana01@users.noreply.github.com> Date: Mon, 15 Sep 2025 14:31:04 +0200 Subject: [PATCH 4/4] fixing typo --- .../src/com/espressif/idf/ui/tools/ToolsJob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5af4736cd..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 @@ -491,7 +491,7 @@ protected IStatus runCommand(List arguments, MessageConsoleStream consol Logger.log("Environment Variables after filtering from system:"); IDFUtil.cleanUpSystemEnvironment(environment); - Logger.log(environment); + Logger.log(environment.toString()); Process process = processRunner.run(arguments, org.eclipse.core.runtime.Path.ROOT, environment); IStatus status = processData(process);