From cd1049ededa4dc694c360b53801d12fdcaa0bb3d Mon Sep 17 00:00:00 2001 From: jllllll <3887729+jllllll@users.noreply.github.com> Date: Thu, 21 Sep 2023 21:52:29 -0500 Subject: [PATCH] Add Conda env deactivation to installer scripts Avoids conflicts with existing Conda installations --- cmd_linux.sh | 3 +++ cmd_macos.sh | 4 ++-- cmd_windows.bat | 3 +++ start_linux.sh | 3 +++ start_macos.sh | 3 +++ start_windows.bat | 3 +++ update_linux.sh | 3 +++ update_macos.sh | 3 +++ update_windows.bat | 3 +++ wsl.sh | 4 ++-- 10 files changed, 28 insertions(+), 4 deletions(-) diff --git a/cmd_linux.sh b/cmd_linux.sh index 0a4ef620..1685050a 100755 --- a/cmd_linux.sh +++ b/cmd_linux.sh @@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")" if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi +# deactivate existing conda envs as needed to avoid conflicts +{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null + # config CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda" INSTALL_ENV_DIR="$(pwd)/installer_files/env" diff --git a/cmd_macos.sh b/cmd_macos.sh index 0cec16e9..1b052e5c 100755 --- a/cmd_macos.sh +++ b/cmd_macos.sh @@ -4,8 +4,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi -# deactivate existing env if needed -conda deactivate 2> /dev/null +# deactivate existing conda envs as needed to avoid conflicts +{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null # config CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda" diff --git a/cmd_windows.bat b/cmd_windows.bat index 606ff485..b219cf66 100755 --- a/cmd_windows.bat +++ b/cmd_windows.bat @@ -10,6 +10,9 @@ echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which c set TMP=%cd%\installer_files set TEMP=%cd%\installer_files +@rem deactivate existing conda envs as needed to avoid conflicts +(conda deactivate && conda deactivate && conda deactivate) 2>null + @rem config set CONDA_ROOT_PREFIX=%cd%\installer_files\conda set INSTALL_ENV_DIR=%cd%\installer_files\env diff --git a/start_linux.sh b/start_linux.sh index dc37f612..1de8ccdf 100755 --- a/start_linux.sh +++ b/start_linux.sh @@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")" if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi +# deactivate existing conda envs as needed to avoid conflicts +{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null + OS_ARCH=$(uname -m) case "${OS_ARCH}" in x86_64*) OS_ARCH="x86_64";; diff --git a/start_macos.sh b/start_macos.sh index a813edb3..131a8af5 100755 --- a/start_macos.sh +++ b/start_macos.sh @@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")" if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi +# deactivate existing conda envs as needed to avoid conflicts +{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null + # M Series or Intel OS_ARCH=$(uname -m) case "${OS_ARCH}" in diff --git a/start_windows.bat b/start_windows.bat index 4f5b0ba5..3140f70f 100755 --- a/start_windows.bat +++ b/start_windows.bat @@ -17,6 +17,9 @@ set SPCHARMESSAGE= set TMP=%cd%\installer_files set TEMP=%cd%\installer_files +@rem deactivate existing conda envs as needed to avoid conflicts +(conda deactivate && conda deactivate && conda deactivate) 2>null + @rem config set INSTALL_DIR=%cd%\installer_files set CONDA_ROOT_PREFIX=%cd%\installer_files\conda diff --git a/update_linux.sh b/update_linux.sh index f7be8440..e641fafb 100755 --- a/update_linux.sh +++ b/update_linux.sh @@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")" if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi +# deactivate existing conda envs as needed to avoid conflicts +{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null + # config CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda" INSTALL_ENV_DIR="$(pwd)/installer_files/env" diff --git a/update_macos.sh b/update_macos.sh index f7be8440..e641fafb 100755 --- a/update_macos.sh +++ b/update_macos.sh @@ -4,6 +4,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")" if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi +# deactivate existing conda envs as needed to avoid conflicts +{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null + # config CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda" INSTALL_ENV_DIR="$(pwd)/installer_files/env" diff --git a/update_windows.bat b/update_windows.bat index a44e2188..6f01ee03 100755 --- a/update_windows.bat +++ b/update_windows.bat @@ -10,6 +10,9 @@ echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which c set TMP=%cd%\installer_files set TEMP=%cd%\installer_files +@rem deactivate existing conda envs as needed to avoid conflicts +(conda deactivate && conda deactivate && conda deactivate) 2>null + @rem config set CONDA_ROOT_PREFIX=%cd%\installer_files\conda set INSTALL_ENV_DIR=%cd%\installer_files\env diff --git a/wsl.sh b/wsl.sh index 50b8d77d..73a20a86 100755 --- a/wsl.sh +++ b/wsl.sh @@ -15,8 +15,8 @@ read -n1 -p "Continue the installer anyway? [y,n]" EXIT_PROMPT if ! [[ $EXIT_PROMPT == "Y" || $EXIT_PROMPT == "y" ]]; then exit; fi fi -# deactivate any currently active conda env -conda deactivate 2> /dev/null +# deactivate existing conda envs as needed to avoid conflicts +{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null # config unlike other scripts, can't use current directory due to file IO bug in WSL, needs to be in virtual drive INSTALL_DIR="$HOME/text-gen-install"