From 22cebaa1d955ee6eb3add4f923e3649d164bd187 Mon Sep 17 00:00:00 2001 From: Jacob Mims Date: Tue, 26 Mar 2024 16:20:23 -0400 Subject: [PATCH] remove old conda envs if found on build --- src/conda/conda_env_setup.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/conda/conda_env_setup.sh b/src/conda/conda_env_setup.sh index 67b0a2239..6bbf6ba9e 100755 --- a/src/conda/conda_env_setup.sh +++ b/src/conda/conda_env_setup.sh @@ -166,8 +166,15 @@ if [ "$make_envs" = "true" ]; then else conda_prefix="${_CONDA_ENV_ROOT}/${env_name}" fi + echo "$conda_prefix" + if [ -d "$conda_prefix" ]; then + # remove conda env of same name + echo "Removing previous conda env ${env_name}..." + conda remove -q -y -n "$env_name" --all + echo "... previous env ${env_name} removed." + fi echo "Creating conda env ${env_name} in ${conda_prefix}..." - "$_INSTALL_EXE" env create --force -q -p="$conda_prefix" -f="$env_file" + "$_INSTALL_EXE" env create -q -p="$conda_prefix" -f="$env_file" echo "... conda env ${env_name} created." done "$_INSTALL_EXE" clean -aqy @@ -196,4 +203,4 @@ fi echo "\"\${_mdtf}/mdtf_framework.py\" \"\$@\"" >> "$_CONDA_WRAPPER" echo "exit \$?" >> "$_CONDA_WRAPPER" chmod +x "$_CONDA_WRAPPER" -echo "Created MDTF wrapper script at ${_CONDA_WRAPPER}" \ No newline at end of file +echo "Created MDTF wrapper script at ${_CONDA_WRAPPER}"