From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 25 11:03:58 2020 Received: (at submit) by debbugs.gnu.org; 25 Aug 2020 15:03:58 +0000 Received: from localhost ([127.0.0.1]:35674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAaUQ-0004z6-D2 for submit@debbugs.gnu.org; Tue, 25 Aug 2020 11:03:58 -0400 Received: from lists.gnu.org ([209.51.188.17]:52386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAaUO-0004yx-0J for submit@debbugs.gnu.org; Tue, 25 Aug 2020 11:03:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAaUN-0007AO-QY for bug-guix@gnu.org; Tue, 25 Aug 2020 11:03:55 -0400 Received: from mail-pg1-f179.google.com ([209.85.215.179]:34526) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kAaU7-0002mt-Mp for bug-guix@gnu.org; Tue, 25 Aug 2020 11:03:55 -0400 Received: by mail-pg1-f179.google.com with SMTP id i10so7019958pgk.1 for ; Tue, 25 Aug 2020 08:03:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vuwKIn4ZqJeHp9eSZqKpTP6VpMWffT/cwvHfdtrnixk=; b=N/IBRpJ27/pNmdTvCPLgr8MchSrC7X1dLQWQziEGa4jV72vlDo9bMOHLgyZDyTvcAy UByvngxlrbzNxZz5IPhvZZaKGlFQXzBHNA8t5dNvqaQAxSKzNiy95+Qyq9E7kN2fsXaQ ufHZnDZxbsOglXoQchWucTigAk6wv2r126hGcppAzr3eEsfcGrhiue9P51zlnoo7hTmf 0tO4i8BgK5NbAmaYQl2fTMEWsUDc8VlMhYph9eZHqA8grDqJL+3cf6Mdz+w3hIiK6EYY liH/7wffeDhRz/zozknJHD0++QKL5QaU7SoAU1sRWEWzkVyFRNuCbqrkLuwlC/QfNTgW 43zA== X-Gm-Message-State: AOAM531hR9XptXSupdbILs1SDgF+EWhO5DkE9GYzY26Lqv47/HZ1U6it CRR7SuuVSxz4yJRZwn1rkoimnFOGqwoSh2ANW1hQEmkrv4pV7w== X-Google-Smtp-Source: ABdhPJwJevNLB+oYhXtd2ULd+UH5FKiGS/oc+AB36XsW287DmTXKj8UzsJ1+fZ/rW/oK8ADNSbwGUEdUmslnqq/DbGA= X-Received: by 2002:a17:902:eec4:: with SMTP id h4mr2976110plb.241.1598367817354; Tue, 25 Aug 2020 08:03:37 -0700 (PDT) MIME-Version: 1.0 References: <87blj7x841.fsf@elephly.net> <87364gy7tw.fsf@elephly.net> <87imd6x5to.fsf@elephly.net> In-Reply-To: <87imd6x5to.fsf@elephly.net> From: Hugo Buddelmeijer Date: Tue, 25 Aug 2020 17:03:26 +0200 Message-ID: Subject: Re: conda 4.8.3 on guix cannot activate environments To: Ricardo Wurmus Content-Type: multipart/alternative; boundary="000000000000f952be05adb5015a" Received-SPF: pass client-ip=209.85.215.179; envelope-from=blackshift@gmail.com; helo=mail-pg1-f179.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/25 11:03:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.8 (/) X-Debbugs-Envelope-To: submit Cc: bug-guix@gnu.org, 42920@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.8 (-) --000000000000f952be05adb5015a Content-Type: text/plain; charset="UTF-8" Hi Ricardo, On Tue, 25 Aug 2020 at 14:35, Ricardo Wurmus 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`: https://github.com/conda/conda/blob/master/conda/shell/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 "$CONDA_EXE" $_CE_M $_CE_CONDA 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. Cheers, Hugo --000000000000f952be05adb5015a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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= 9; has bash
> as interpreter, and "non-interactive bashes go out of their way t= o unset
> PS1":
> https= ://superuser.com/questions/663069/why-does-subshell-not-inherit-exported-va= riable-ps1
> https://tldp.org/HOWTO/Bash-Prompt-HOWTO/set= ps.html

Good sleuthing!

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

I did some more experiments, and forcing the wrappe= r 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 functi= on (and associated functions).

The output from `co= nda 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
"$CONDA_E= XE" $_CE_M $_CE_CONDA
in that file with
bash --nor= c -i "$CONDA_EXE" $_CE_M $_CE_CONDA
then everything wor= ks as expected.

The -i is to enable interactive mo= de, preventing PS1 from being eaten. --norc is necessary to not source .bas= hrc.
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 o= n a single file. It is a bit hackish, because it adds knowledge to the pack= age 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. Ma= ybe I can try to update the package too.

Other= options:
- Use some other sh than bash, one that does not eat PS= 1, (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?
- Some= how let conda work with another variable than PS1. Seems more complicated.<= /div>

Then what is left is updating `conda init` such th= at
- 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.

Cheers,
Hugo<= /div>

--000000000000f952be05adb5015a--