Just sharing a bit of more info about why the conda prompt breaks.

On Fri, 21 Aug 2020 at 05:52, Ricardo Wurmus <rek...@elephly.net> wrote:

>
> Hugo Buddelmeijer <h...@buddelmeijer.nl> writes:
>
> > 2. The prompt is not set correctly, as in, what should happen is that the
> > current conda environment is added to the prompt. Instead, the prompt is
> > replaced entirely by the environment. This shouldn't be too hard to fix
> > manually though.
>
> Weird!  Is this something Conda does wrong because it assumes too much
> about the existing prompt?
>

This is what happens, reducing the files to the essence:

1) .bashrc runs

__conda_setup="$('/gnu/store/ihn8dbs84rmc3ai7r1vkvh4cya518wmx-conda-4.8.3/bin/conda'
'shell.bash' 'hook' 2> /dev/null)"
eval "$__conda_setup"

2) __conda_setup runs

__conda_activate() {
    ask_conda="$(PS1="$PS1" "$CONDA_EXE" $_CE_M $_CE_CONDA shell.posix
"$cmd" "$@")" || \return $?
    \eval "$ask_conda"
}
conda activate base

3) ask_conda will contain the new PS1 definition. The command ran to create
ask_conda  is

PS1="\u@\h \w\$"
"/gnu/store/ihn8dbs84rmc3ai7r1vkvh4cya518wmx-conda-4.8.3/bin/conda"
shell.posix "activate" "base"

4) conda runs

#!/gnu/store/pwcp239kjf7lnj5i4lkdzcfcxwcfyk72-bash-minimal-5.0.16/bin/bash
export PYTHONPATH="/gnu/store....."
exec -a "$0"
"/gnu/store/ihn8dbs84rmc3ai7r1vkvh4cya518wmx-conda-4.8.3/bin/.conda-real"
"$@"

5) .conda.real generates the prompt in Python:

from conda.cli import main
sys.exit(main())

6) .conda.real outputs
PS1='(base) '
export PATH='...

The problem with the prompt arises from step 4), because 'conda' has bash
as interpreter, and "non-interactive bashes go out of their way to unset
PS1":
https://superuser.com/questions/663069/why-does-subshell-not-inherit-exported-variable-ps1
https://tldp.org/HOWTO/Bash-Prompt-HOWTO/setps.html

So .conda.real never gets the PS1 variable and it disappears.

I don't really understand why there is a bash function, a conda bash script
and a .conda-real python script.

My local miniconda 4.8.3 installation on an Ubuntu machine (in my home
directory) does not have a ".conda-real": "conda" directly is the Python
script, so everything works.

Maybe more later.

Hugo



> --
> Ricardo
>

Reply via email to