Hi Ricardo,

On Tue, 25 Aug 2020 at 14:35, Ricardo Wurmus <rekado@elephly.net> wrote:

> 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

Good sleuthing!

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

I did some more experiments, and forcing the wrapper script to start in interactive mode solves the problem.

`conda init` adds some things to `.bashrc`, in particular it `eval`s the output from `conda shell.bash hook`, which creates the `conda` bash function (and associated functions).

The output from `conda shell.bash hook` seems to be based on `/etc/profile.d/conda.sh`:
As in, it prefixes some environment variables and appends the activation of the base environment.

Now if we replace all 5 occurances of
in that file with
bash --norc -i "$CONDA_EXE" $_CE_M $_CE_CONDA
then everything works as expected.

The -i is to enable interactive mode, preventing PS1 from being eaten. --norc is necessary to not source .bashrc.
There are two occurences of "$CONDA_EXE" that should not be replaced, hence adding the CE variables.

Would editing files like that be possible in a guix package script?

It seems that it is only a simple sed replace on a single file. It is a bit hackish, because it adds knowledge to the package that a) there is a wrapper script and b) it is in bash.

I have only experimented with it by copying the output off `conda shell.bash hook` to a file in my home directory and editing that. Maybe I can try to update the package too.

Other options:
- Use some other sh than bash, one that does not eat PS1, (e.g. dash) as wrapper script. I just verified that *all* wrappers on my machine are bash. However, some are using bash-minimal, so that means that there is a choice, so maybe switching shells is possible?
- Somehow let conda work with another variable than PS1. Seems more complicated.

Then what is left is updating `conda init` such that
- it doesn't complain when it cannot edit files
- it only uses paths in ~/.guix-profile
but this is not essential to get conda to work.