mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
#RUBY-16963: pkexec failed to execute ruby bundler without parent environment
This commit is contained in:
+1
-1
@@ -146,7 +146,7 @@ public class GeneralCommandLine implements UserDataHolder {
|
||||
* @return unmodifiable map of the parent environment, that will be passed to the process if isPassParentEnvironment() == true
|
||||
*/
|
||||
@NotNull
|
||||
public Map<String, String> getParentEnvironment() {
|
||||
public static Map<String, String> getParentEnvironment() {
|
||||
return PlatformUtils.isAppCode() ? System.getenv() // Temporarily fix for OC-8606
|
||||
: EnvironmentUtil.getEnvironmentMap();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -217,7 +219,16 @@ public class ExecUtil {
|
||||
final List<String> sudoCommand = new ArrayList<String>();
|
||||
sudoCommand.add("pkexec");
|
||||
sudoCommand.addAll(command);
|
||||
return new GeneralCommandLine(sudoCommand).withWorkDirectory(workDir).withEnvironment(environment).createProcess();
|
||||
|
||||
final Map<String, String> parentEnvironment = GeneralCommandLine.getParentEnvironment();
|
||||
final Map<String, String> inheritedEnvironment = ContainerUtilRt.newHashMap(parentEnvironment.size());
|
||||
|
||||
for (Map.Entry<String, String> envVariable : parentEnvironment.entrySet()) {
|
||||
inheritedEnvironment.put(envVariable.getKey(), escapeUnixShellArgument(envVariable.getValue()));
|
||||
}
|
||||
inheritedEnvironment.putAll(environment);
|
||||
|
||||
return new GeneralCommandLine(sudoCommand).withWorkDirectory(workDir).withEnvironment(inheritedEnvironment).createProcess();
|
||||
}
|
||||
else if (SystemInfo.isUnix && hasTerminalApp()) {
|
||||
final String escapedCommandLine = StringUtil.join(command, new Function<String, String>() {
|
||||
|
||||
Reference in New Issue
Block a user