[gnome-builder] subprocess: Set a few env vars when clearing parent



commit 85dedadc0b7e9522cbe858c1ae9608377d25e73a
Author: Matthew Leeds <mleeds redhat com>
Date:   Thu Feb 9 21:18:25 2017 -0600

    subprocess: Set a few env vars when clearing parent
    
    Many programs (jhbuild and gcc for example) don't work properly if basic
    environment variables like PATH and HOME aren't set, so we should set
    them even if we're clearing the parent process's environment.

 libide/subprocess/ide-subprocess-launcher.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/libide/subprocess/ide-subprocess-launcher.c b/libide/subprocess/ide-subprocess-launcher.c
index cb8c1c0..fcbd7fd 100644
--- a/libide/subprocess/ide-subprocess-launcher.c
+++ b/libide/subprocess/ide-subprocess-launcher.c
@@ -231,6 +231,14 @@ ide_subprocess_launcher_spawn_worker (GTask        *task,
 
   g_return_if_fail (IDE_IS_SUBPROCESS_LAUNCHER (self));
 
+  /* Many things break without at least PATH, HOME, etc. being set */
+  if (priv->clear_env)
+    {
+      ide_subprocess_launcher_setenv (self, "PATH", "/bin:/usr/bin", FALSE);
+      ide_subprocess_launcher_setenv (self, "HOME", g_get_home_dir (), FALSE);
+      ide_subprocess_launcher_setenv (self, "USER", g_get_user_name (), FALSE);
+    }
+
 #ifdef IDE_ENABLE_TRACE
   {
     g_autofree gchar *str = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]