Skip to content

Commit 8a1fc12

Browse files
committed
fix(eim_cli): fixed the eim cli launch getting obstructed due to eclipse cdt env
1 parent b2e5f27 commit 8a1fc12

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/EimButtonLaunchListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ protected IStatus run(IProgressMonitor monitor)
8787
{
8888
try
8989
{
90-
EimGuiOrCliLauncher.launch(toolInitializer, eimLoader,
91-
idfEnvironmentVariables.getEnvValue(IDFEnvironmentVariables.EIM_PATH), standardConsoleStream,
90+
String resolvedEimPath = toolInitializer.resolveEimExecutablePath(null);
91+
EimGuiOrCliLauncher.launch(toolInitializer, eimLoader, resolvedEimPath, standardConsoleStream,
9292
display, EimButtonLaunchListener.this::refreshAfterEimClose);
9393
}
9494
catch (IOException e)

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/EimGuiOrCliLauncher.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,20 @@ private EimGuiOrCliLauncher()
3434
public static void launch(ToolInitializer toolInitializer, EimLoader eimLoader, String eimPath,
3535
MessageConsoleStream standardConsoleStream, Display display, Runnable afterEimClosed) throws IOException
3636
{
37+
if (eimPath == null || eimPath.isBlank())
38+
{
39+
Logger.log("EIM launch aborted: path is null or empty"); //$NON-NLS-1$
40+
return;
41+
}
42+
3743
if (toolInitializer.isEimGuiCapable(eimPath))
3844
{
3945
Logger.log("EIM binary supports GUI mode, launching GUI"); //$NON-NLS-1$
4046
LaunchResult launchResult = eimLoader.launchEimWithResult(eimPath, "gui"); //$NON-NLS-1$
4147
eimLoader.waitForEimClosure(launchResult, afterEimClosed);
4248
return;
4349
}
44-
50+
4551
Logger.log("EIM binary does not support GUI mode, launching CLI terminal"); //$NON-NLS-1$
4652
EimJsonWatchService.getInstance().pauseListeners();
4753
display.syncExec(() -> {

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/eim/terminal/EimCliTerminalLaunchSupport.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public static CompletableFuture<?> launch(String eimExecutablePath, Runnable onC
4343
if (StringUtil.isEmpty(eimExecutablePath) || onComplete == null)
4444
{
4545
Logger.log("EIM CLI terminal launch skipped: missing path or callback"); //$NON-NLS-1$
46+
if (onComplete != null)
47+
{
48+
Display.getDefault().asyncExec(onComplete);
49+
}
4650
return CompletableFuture.completedFuture(null);
4751
}
4852

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/eim/terminal/EimCliTerminalLauncherDelegate.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.eclipse.terminal.view.ui.launcher.IConfigurationPanel;
3030
import org.eclipse.terminal.view.ui.launcher.IConfigurationPanelContainer;
3131

32-
import com.espressif.idf.core.IDFEnvironmentVariables;
3332
import com.espressif.idf.core.logging.Logger;
3433
import com.espressif.idf.ui.tools.Messages;
3534

@@ -120,11 +119,19 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
120119
String userHome = System.getProperty("user.home"); //$NON-NLS-1$
121120
processSettings.setWorkingDir(userHome != null && !userHome.isBlank() ? userHome : "."); //$NON-NLS-1$
122121

123-
// Build a merged environment: System.getenv() + CDT build env + package-manager PATH entries
124-
Map<String, String> envMap = new IDFEnvironmentVariables().getSystemEnvMap();
122+
// Use ONLY the native system environment (no CDT/IDF toolchain variables) so EIM's
123+
// prerequisite checks (Python SSL, git, cmake) use system-installed tools, not IDF-bundled ones
124+
Map<String, String> envMap = new java.util.HashMap<>(System.getenv());
125125
String pathPrefix = computePackageManagerPathPrefix(envMap);
126126
enrichPathWithPackageManagers(envMap);
127127

128+
// Remove IDF-specific env vars that could pollute EIM's subprocess checks
129+
envMap.remove("IDF_PATH"); //$NON-NLS-1$
130+
envMap.remove("IDF_TOOLS_PATH"); //$NON-NLS-1$
131+
envMap.remove("IDF_PYTHON_ENV_PATH"); //$NON-NLS-1$
132+
envMap.remove("PYTHONPATH"); //$NON-NLS-1$
133+
envMap.remove("PYTHONHOME"); //$NON-NLS-1$
134+
128135
// Ensure TERM is set so interactive CLI tools (arrow-key menus, coloured output) work correctly
129136
if (!envMap.containsKey("TERM")) //$NON-NLS-1$
130137
{

0 commit comments

Comments
 (0)