JuliaPy / Conda.jl

Conda managing Julia binary dependencies
Other
174 stars 57 forks source link

Failed to add any package on Mac OS #145

Open Michelle-NYX opened 5 years ago

Michelle-NYX commented 5 years ago

After successfully added and built Conda package, I cannot add any library (NumPy or matplotlib) with the following error:

ERROR: File or directory already exists: '/Users/NYX/miniconda3'
If you want to update an existing installation, use the -u option.
ERROR: failed process: Process(`/Users/NYX/.julia/conda/3/installer.sh -b -f -p /Users/NYX/.julia/conda/3`, ProcessExited(1)) [1]
Stacktrace:
 [1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
 [2] pipeline_error at ./process.jl:785 [inlined]
 [3] #run#515(::Bool, ::Function, ::Cmd) at ./process.jl:726
 [4] run at ./process.jl:724 [inlined]
 [5] _install_conda(::String, ::Bool) at /Users/NYX/.julia/packages/Conda/CpuvI/src/Conda.jl:165
 [6] _install_conda(::String) at /Users/NYX/.julia/packages/Conda/CpuvI/src/Conda.jl:152
 [7] runconda(::Cmd, ::String) at /Users/NYX/.julia/packages/Conda/CpuvI/src/Conda.jl:111
 [8] add at /Users/NYX/.julia/packages/Conda/CpuvI/src/Conda.jl:183 [inlined] (repeats 2 times)
 [9] top-level scope at none:0

It doesn't help if I remove and re-install the Conda. I've also tried to delete the /miniconda3 folder, which doesn't help as well.

tkf commented 5 years ago

What happens if you do

rm -rf /Users/NYX/.julia/conda/3
bash /Users/NYX/.julia/conda/3/installer.sh -b -f -p /Users/NYX/.julia/conda/3

in your system shell? Also, what bash /Users/NYX/.julia/conda/3/installer.sh -h prints?

Quar commented 5 years ago

I think this was caused by issues with detecting conda executable in Conda.jl#L80 and Conda.jl#L152, since update conda@4.4.0#recommended-change-to-enable-conda-in-your-shell.

Basically executable conda will only exists in base environment like $HOME/miniconda3/bin, and no longer duplicates under other environment like $HOME/miniconda3/envs/conda_jl/bin. Locating conda executable is recommended through environment variable $CONDA_EXE (which will point to $HOME/miniconda3/bin by default).

Note that this issue occurs for new installation of conda=>4.4.0, and will impact IJulia when try to call noteboook().

146 is intended to address this issue.

More reference to CONDA_EXE:

stevengj commented 5 years ago

The whole point of Conda.jl is to install its own Miniconda distro, independent of whatever you may happen to have installed on your system. It should not be using the conda in $HOME/miniconda3/bin unless you specifically told it to by setting CONDA_JL_HOME and re-building Conda.

In particular, Conda.jl intentionally ignores the value of CONDA_EXE and any other CONDA_* environment variables.

It sounds like we may also need to sanitize the environment when running the miniconda installer?

tkf commented 5 years ago

unless you specifically told it to by setting CONDA_JL_HOME and re-building Conda

I think what @Quar is saying is exactly that case. See #146 for more discussion. I think custom CONDA_JL_HOME case can be improved more and #146 is a nice way forward. (I haven't had chance to review @Quar's other branch linked in that PR yet.)

Having said that, I don't know if @Michelle-NYX's original problem is due to CONDA_JL_HOME.

It sounds like we may also need to sanitize the environment when running the miniconda installer?

It looks like Miniconda3 installer (v4.5.12) does not look at CONDA_EXE.

$ grep -a CONDA_ Miniconda3-latest-Linux-x86_64.sh
__conda_setup="\$(CONDA_REPORT_ERRORS=false '$PREFIX/bin/conda' shell.bash hook 2> /dev/null)"
        CONDA_CHANGEPS1=false conda activate base

and these CONDA_* does not seem to be used at install time (they are written to bashrc):

$ grep -a CONDA_ Miniconda3-latest-Linux-x86_64.sh -C5
        fi
        cat <<EOF >> "$BASH_RC"
# added by Miniconda3 4.5.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="\$(CONDA_REPORT_ERRORS=false '$PREFIX/bin/conda' shell.bash hook 2> /dev/null)"
if [ \$? -eq 0 ]; then
    \\eval "\$__conda_setup"
else
    if [ -f "$PREFIX/etc/profile.d/conda.sh" ]; then
        . "$PREFIX/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \\export PATH="$PREFIX/bin:\$PATH"
    fi
fi
unset __conda_setup
tkf commented 5 years ago

@Michelle-NYX Do you remember if you set CONDA_JL_HOME when you had the error?