From 8eb7c9ad563096af7fc4acf256852575eb5a9096 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Sat, 15 Jan 2022 18:51:50 -0500 Subject: [PATCH] Check if CONDA_JL_CONDA_EXE exists & executable. Install only in ROOTENV --- deps/build.jl | 11 +++++++++-- src/Conda.jl | 13 +++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/deps/build.jl b/deps/build.jl index ee9d005..d4b3634 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -79,13 +79,20 @@ if haskey(ENV, "CONDA_JL_CONDA_EXE") if uperm(CONDA_EXE) & 0x01 > 0 @info "Executable conda located." CONDA_EXE else - error("$CONDA_EXE cannot be executed by the current user.") + error("CONDA_JL_CONDA_EXE, $CONDA_EXE, cannot be executed by the current user.") end else - error("$CONDA_EXE does not exist.") + error("CONDA_JL_CONDA_EXE, $CONDA_EXE, does not exist.") + end +else + if !isfile(CONDA_EXE) + # An old CONDA_EXE has gone missing, revert to default in ROOTENV + @info "CONDA_EXE not found. Reverting to default in ROOTENV" CONDA_EXE ROOTENV + CONDA_EXE = DefaultDeps.default_conda_exe(ROOTENV) end end + deps = """ const ROOTENV = "$(escape_string(ROOTENV))" const MINICONDA_VERSION = "$(escape_string(MINICONDA_VERSION))" diff --git a/src/Conda.jl b/src/Conda.jl index 0d7c520..72f668a 100644 --- a/src/Conda.jl +++ b/src/Conda.jl @@ -189,24 +189,21 @@ _quiet() = get(ENV, "CI", "false") == "true" ? `-q` : `` "Install miniconda if it hasn't been installed yet; _install_conda(true) installs Conda even if it has already been installed." function _install_conda(env::Environment, force::Bool=false) if force || !isfile(Conda.conda) - # This assumes that the conda executable will in some directory under - # CONDA_EXE_PREFIX. - # Ex: If CONDA_EXE="$HOME/miniforge3/bin/conda", then CONDA_EXE_PREFIX="$HOME/miniforge3" - CONDA_EXE_PREFIX = conda |> dirname |> dirname + @assert startswith(abspath(Conda.conda), abspath(PREFIX)) "CONDA_EXE, $(conda), does not exist within $PREFIX" @info("Downloading miniconda installer ...") if Sys.isunix() - installer = joinpath(CONDA_EXE_PREFIX, "installer.sh") + installer = joinpath(PREFIX, "installer.sh") end if Sys.iswindows() - installer = joinpath(CONDA_EXE_PREFIX, "installer.exe") + installer = joinpath(PREFIX, "installer.exe") end - mkpath(CONDA_EXE_PREFIX) + mkpath(PREFIX) Downloads.download(_installer_url(), installer) @info("Installing miniconda ...") if Sys.isunix() chmod(installer, 33261) # 33261 corresponds to 755 mode of the 'chmod' program - run(`$installer -b -f -p $CONDA_EXE_PREFIX`) + run(`$installer -b -f -p $PREFIX`) end if Sys.iswindows() run(Cmd(`$installer /S --no-shortcuts /NoRegistry=1 /AddToPath=0 /RegisterPython=0 /D=$PREFIX`, windows_verbatim=true))