# https://github.com/conda/conda/issues/1679:
#  Internally R_system() calls system() which
# uses /bin/sh to launch various programs. If
# /bin/sh is called with LD_LIBRARY_PATH that
# loads condas shared libraries things break.
#  It may be that not setting LD_LIBRARY_PATH
# causes other things to break, in which case
# R_system() will need to be modified so that
# it calls execve() with an environment which
# has these modifications to LD_LIBRARY_PATH
# removed which may be tricky to orchestrate
if [ "$(uname -s)" == "Linux" ]; then
  return 0
fi
: ${JAVA_HOME=/usr/lib/jvm/java/jre}
: ${R_JAVA_LD_LIBRARY_PATH=/usr/lib/jvm/java/jre/lib/amd64/server}
if test -n "/opt/anaconda1anaconda2anaconda3/lib"; then
: ${R_LD_LIBRARY_PATH=${R_HOME}/lib:/opt/anaconda1anaconda2anaconda3/lib}
else
: ${R_LD_LIBRARY_PATH=${R_HOME}/lib}
fi
if test -n "${R_JAVA_LD_LIBRARY_PATH}"; then
  R_LD_LIBRARY_PATH="${R_LD_LIBRARY_PATH}:${R_JAVA_LD_LIBRARY_PATH}"
fi
## This is DYLD_FALLBACK_LIBRARY_PATH on Darwin (OS X) and
## LD_LIBRARY_PATH elsewhere.
## However, on OS X 10.11 (if SIP is enabled, the default), the
## environment value will not be passed to a script such as R.sh, so
## would not seen here.
if test -z "${LD_LIBRARY_PATH}"; then
  LD_LIBRARY_PATH="${R_LD_LIBRARY_PATH}"
else
  LD_LIBRARY_PATH="${R_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}"
fi
export LD_LIBRARY_PATH
