diff --git a/tljh/conda.py b/tljh/conda.py index df9a027..ca849e8 100644 --- a/tljh/conda.py +++ b/tljh/conda.py @@ -98,7 +98,7 @@ def install_miniconda(installer_path, prefix): fix_permissions(prefix) -def ensure_conda_packages(prefix, packages): +def ensure_conda_packages(prefix, packages, force=False): """ Ensure packages (from conda-forge) are installed in the conda prefix. @@ -110,13 +110,16 @@ def ensure_conda_packages(prefix, packages): # fallback on conda if mamba is not present (e.g. for mamba to install itself) conda_executable = os.path.join(prefix, "bin", "conda") + cmd = [conda_executable, "install", "--yes"] + + if force: + cmd += ["--force"] + abspath = os.path.abspath(prefix) utils.run_subprocess( - [ - conda_executable, - "install", - "-y", + cmd + + [ "-c", "conda-forge", # Make customizable if we ever need to "--prefix", diff --git a/tljh/installer.py b/tljh/installer.py index b65ddac..8c429ec 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -249,6 +249,8 @@ def ensure_user_environment(user_requirements_txt_file): # we _could_ explicitly pin Python here, # but conda already does this by default cf_pkgs_to_upgrade, + # use force to avoid RemoveError: 'requests' is a dependency of conda + force=True, ) pypi_pkgs_to_upgrade = list(set(to_upgrade) & {"pip"}) if pypi_pkgs_to_upgrade: