diff options
| -rw-r--r-- | src/lib/core/conda.c | 28 | 
1 files changed, 18 insertions, 10 deletions
| diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c index a696744..4533803 100644 --- a/src/lib/core/conda.c +++ b/src/lib/core/conda.c @@ -208,23 +208,26 @@ int conda_exec(const char *args) {  }  static int conda_prepend_bin(const char *root) { -    const char *system_path_old = getenv("PATH");      char conda_bin[PATH_MAX] = {0}; -    snprintf(conda_bin, sizeof(conda_bin) - 1, "%s/bin:%s/condabin", root, root); +    snprintf(conda_bin, sizeof(conda_bin) - 1, "%s/bin", root); +    if (path_manip(conda_bin, PM_PREPEND | PM_ONCE)) { +        return -1; +    } +    return 0; +} -    if (!strstr(system_path_old, conda_bin)) { -        // conda_bin is not present in PATH. Add it to the head. -        char system_path_new[STASIS_BUFSIZ]; -        sprintf(system_path_new, "%s:%s", conda_bin, system_path_old); -        if (setenv("PATH", system_path_new, 1) < 0) { -            SYSERROR("Unable to prepend to PATH: %s", conda_bin); -            return -1; -        } +static int conda_prepend_condabin(const char *root) { +    char conda_condabin[PATH_MAX] = {0}; + +    snprintf(conda_condabin, sizeof(conda_condabin) - 1, "%s/condabin", root); +    if (path_manip(conda_condabin, PM_PREPEND | PM_ONCE)) { +        return -1;      }      return 0;  } +  int conda_activate(const char *root, const char *env_name) {      FILE *fp = NULL;      const char *init_script_conda = "/etc/profile.d/conda.sh"; @@ -274,6 +277,11 @@ int conda_activate(const char *root, const char *env_name) {          conda_shlvl = strtol(conda_shlvl_str, NULL, 10);      } +    if (conda_prepend_condabin(root)) { +        remove(logfile); +        return -1; +    } +      if (conda_prepend_bin(root)) {          remove(logfile);          return -1; | 
