From: FX (fxcoudert_at_gmail.com)
Date: Sun Apr 26 2020 - 04:49:57 CDT

> Would you accept a patch to add code in macosxvmdstart.C that auto-detects its presence in PATH? Currently, VMD expects VMDBABELBIN to be set, even if I have an obabel binary in my PATH. In my case, I have open babel installed and VMD won’t use it, which is not an ideal experience.

Here is code that works for me:

char *find_babel(void) {
  char *token, *s, *path;
  char tmp[1024];

  path = s = strdup(getenv("PATH"));
  while ((token = strsep(&s, ":"))) {
    strcpy(tmp, token);
    strcat(tmp, "/obabel");
    if (access(tmp, X_OK) == 0) {
      printf("Info) Found Open Babel binary at: %s\n", tmp);
      free(path);
      return strdup(tmp);
    }
  }

  free(path);
  return NULL;
}

and then at the end of macosxvmdstart():

  if (!getenv("VMDBABELBIN")) {
    char *babel = find_babel();
    setenv("VMDBABELBIN", babel, 1);
    free(babel);
  }

That way it does not override an explicit environment variable, but will auto-detect babel if it’s installed in the PATH.

FX