Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Terminal ESP-IDF Path conflict issues #979

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Changes from all commits
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 @@ -302,6 +302,16 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
.getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_DEFAULT_SHELL_UNIX_ARGS);
}

// Avoding profiles to isolate PATH enviroment
arguments = ""; //$NON-NLS-1$
if (image.contains("bash")) { //$NON-NLS-1$
arguments = "--noprofile --norc"; //$NON-NLS-1$
} else if (image.contains("zsh")) { //$NON-NLS-1$
arguments = "--no-rcs --no-globalrcs"; //$NON-NLS-1$
} else if (image.contains("powershell")) { //$NON-NLS-1$
arguments = "-NoProfile"; //$NON-NLS-1$
}

// Determine if a PTY will be used
boolean isUsingPTY = (properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ) == null
&& PTY.isSupported(PTY.Mode.TERMINAL))
Expand Down Expand Up @@ -375,14 +385,14 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
//Set CDT build environment variables
Map<String, String> envMap = new IDFEnvironmentVariables().getSystemEnvMap();
Set<String> keySet = envMap.keySet();

for (String envKey : keySet) {
String envValue = envMap.get(envKey);
if (envKey.equals("PATH")) //$NON-NLS-1$
{
String idfExtraPaths = IDFUtil.getIDFExtraPaths();
if(!StringUtil.isEmpty(idfExtraPaths))
{
envValue = envValue + ":" + idfExtraPaths; //$NON-NLS-1$
if (!StringUtil.isEmpty(idfExtraPaths)) {
envValue = idfExtraPaths + ":" + envValue; //$NON-NLS-1$
}
}
envpList.add(envKey + "=" + envValue); //$NON-NLS-1$
Expand All @@ -394,11 +404,10 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
Assert.isTrue(image != null || process != null);

String terminalWrkDir = getWorkingDir();
if (StringUtil.isEmpty(terminalWrkDir))
{
if (StringUtil.isEmpty(terminalWrkDir)) {
terminalWrkDir = workingDir;
}

// Construct the terminal settings store
ISettingsStore store = new SettingsStore();

Expand All @@ -420,7 +429,6 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
processSettings
.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean) value).booleanValue() : false);
}

// And save the settings to the store
processSettings.save(store);

Expand All @@ -435,7 +443,7 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties

return connector;
}

protected String getWorkingDir() {
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
Expand Down
Loading