Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -132,6 +133,8 @@ public IStatus getToolsExportOutputFromGivenIdfPath(final String pythonExePath,
addGitToEnvironment(environment, gitExePath);
}

cleanUpSystemEnvironment(environment);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Apply env cleanup to all export paths, not just the “given IDF path” flow.

The conflicting vars will still leak into these two flows:

  • runToolsExportAndProcessOutput(...)
  • getToolsExportOutput(...)

Call cleanUpSystemEnvironment(environment) there as well to make the fix complete.

*** a/.../ExportIDFTools.java
--- b/.../ExportIDFTools.java
@@ public IStatus runToolsExportAndProcessOutput(final String pythonExePath, final String gitExePath, final MessageConsoleStream console, MessageConsoleStream errorConsoleStream)
-        if (gitExePath != null)
-        {
-            addGitToEnvironment(environment, gitExePath);
-        }
+        if (gitExePath != null)
+        {
+            addGitToEnvironment(environment, gitExePath);
+        }
+        cleanUpSystemEnvironment(environment);
@@ public IStatus getToolsExportOutput(final String pythonExePath, final String gitExePath, final MessageConsoleStream console, MessageConsoleStream errorConsoleStream)
-        if (gitExePath != null)
-        {
-            addGitToEnvironment(environment, gitExePath);
-        }
+        if (gitExePath != null)
+        {
+            addGitToEnvironment(environment, gitExePath);
+        }
+        cleanUpSystemEnvironment(environment);

Please also verify Windows tool installation via all three code paths.


🏁 Script executed:

#!/bin/bash
set -eux
# locate ExportIDFTools.java
FILE=$(rg -l "class ExportIDFTools" -g "*.java")
echo "Found file: $FILE"
# show all cleanUpSystemEnvironment calls with context
rg -nP -C3 "cleanUpSystemEnvironment" "$FILE"
# show definitions of target methods with context
echo "\nMethod runToolsExportAndProcessOutput definition with context:"
rg -nP -C3 "public IStatus runToolsExportAndProcessOutput" "$FILE"
echo "\nMethod getToolsExportOutput definition with context:"
rg -nP -C3 "public IStatus getToolsExportOutput" "$FILE"

Length of output: 2461


Add cleanup in all export flows and verify Windows tool installation

  • Insert cleanUpSystemEnvironment(environment); immediately after the addGitToEnvironment(...) block in both runToolsExportAndProcessOutput(...) and getToolsExportOutput(...).
  • Confirm Windows tool installation works correctly across all three export paths.
🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/ExportIDFTools.java
around lines 136-137, add a call to cleanUpSystemEnvironment(environment)
immediately after each addGitToEnvironment(...) call in both
runToolsExportAndProcessOutput(...) and getToolsExportOutput(...); ensure the
cleanup runs on all export code paths (normal, fallback and any Windows-specific
branch) and then run or write tests to verify Windows tool installation succeeds
across all three export flows so the environment is restored and Windows tools
install correctly.

final ProcessBuilderFactory processRunner = new ProcessBuilderFactory();
try
{
Expand All @@ -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<String, String> environment)
{
List<String> keysToRenmove = new LinkedList<>();
keysToRenmove.add(IDFEnvironmentVariables.IDF_PYTHON_ENV_PATH);
keysToRenmove.add(IDFEnvironmentVariables.IDF_PATH);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to exclude other environment variables that have IDF in their name to avoid conflicts? For example, in IDFEnvironmentVariables we also have IDF_CCACHE_ENABLE, IDF_COMPONENT_MANAGER, IDF_MAINTAINER, and ESP_IDF_VERSION, which can potentially affect the plugin's functionality.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that sounds about right I think I missed those
Thanks


for (String key : keysToRenmove)
{
if (environment.containsKey(key))
{
environment.remove(key);
}
}
}

private List<String> getExportCommandUsingGivenIdfPath(String pythonExePath, String idfPath)
{
final List<String> arguments = new ArrayList<>();
Expand Down
Loading