From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yDQdCSM7PWA+LgAA0tVLHw (envelope-from ) for ; Mon, 01 Mar 2021 19:06:11 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id gOTwBCM7PWDSIQAAB5/wlQ (envelope-from ) for ; Mon, 01 Mar 2021 19:06:11 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id E5290112A9 for ; Mon, 1 Mar 2021 20:06:09 +0100 (CET) Received: from localhost ([::1]:47494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGnrs-00077V-MT for larch@yhetil.org; Mon, 01 Mar 2021 14:06:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGndG-0002le-JA for bug-guix@gnu.org; Mon, 01 Mar 2021 13:51:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:39226) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lGndG-0000Gt-BH for bug-guix@gnu.org; Mon, 01 Mar 2021 13:51:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lGndG-0001Sn-8X for bug-guix@gnu.org; Mon, 01 Mar 2021 13:51:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#42920: conda 4.8.3 on guix cannot activate environments Resent-From: Hugo Buddelmeijer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 01 Mar 2021 18:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42920 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ricardo Wurmus X-Debbugs-Original-Cc: bug-guix@gnu.org, 42920@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16146246385586 (code B ref -1); Mon, 01 Mar 2021 18:51:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 Mar 2021 18:50:38 +0000 Received: from localhost ([127.0.0.1]:50770 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGncn-0001Rx-Ud for submit@debbugs.gnu.org; Mon, 01 Mar 2021 13:50:38 -0500 Received: from lists.gnu.org ([209.51.188.17]:41380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGncl-0001Rj-Aq for submit@debbugs.gnu.org; Mon, 01 Mar 2021 13:50:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGnck-0002VH-6k for bug-guix@gnu.org; Mon, 01 Mar 2021 13:50:30 -0500 Received: from mail-pl1-f182.google.com ([209.85.214.182]:36036) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lGnch-0008OU-N6 for bug-guix@gnu.org; Mon, 01 Mar 2021 13:50:29 -0500 Received: by mail-pl1-f182.google.com with SMTP id e9so10477830plh.3 for ; Mon, 01 Mar 2021 10:50:26 -0800 (PST) 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=PPeHai1a3TxBBuOo0aVpeA7X6+PbTjT5YaCFLwVMGgU=; b=iJyIQ1RDNgzV6dJDRLsCVJ8ywrBr+8VCzKSdUARVpF5WJECCte8FRo+nxEl/nr9wSW 0sSLKyN6eBZTmQBSr6R74s67fhoD5o7a091qLpw4FPq9hvRDLiTLG0EPO0DRBrd5T6Vv YmRIYUi+xrBMY6rLFYrAohU5ektl+6UtDvCAjTGF39Tx7unA+9nJNNEmPVoq8ET8nSNx L+ArHJ+IDH9XSpzSPHJYg+EbX1OZSTgVUgZvpcyQ7Si6RPv1C0TtmCT1b5Mz/rzsElCj 4zjTfFkGDd6M30y0RCaLHo3dRWwNLEvkeiM1J4+JJzPpAHphvW2CllW/p6dY8vA8eE9T Mwlw== X-Gm-Message-State: AOAM53247UbcjXZ087JpwtmeC2/itbw0xYarvTn+IZGnGD09Dvv2BTx+ BobXpsMNzAD99e6KVTrCww11s5Yv1y/FT28n5hk= X-Google-Smtp-Source: ABdhPJxg7fuMp3lxK30Q+yzvsmQpl0ZC4p8UfqiKt7RXR/Vghk1QU2ahZU3JEQ6XJ96ZzwWzdaV1X+zAeVJXmZpXNbI= X-Received: by 2002:a17:902:9b91:b029:e3:2c9e:f511 with SMTP id y17-20020a1709029b91b02900e32c9ef511mr16964985plp.74.1614624625134; Mon, 01 Mar 2021 10:50:25 -0800 (PST) MIME-Version: 1.0 References: <87blj7x841.fsf@elephly.net> <87364gy7tw.fsf@elephly.net> <87imd6x5to.fsf@elephly.net> In-Reply-To: From: Hugo Buddelmeijer Date: Mon, 1 Mar 2021 19:50:13 +0100 Message-ID: Content-Type: multipart/alternative; boundary="0000000000003a0e4905bc7e17c8" Received-SPF: pass client-ip=209.85.214.182; envelope-from=blackshift@gmail.com; helo=mail-pl1-f182.google.com 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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Mon, 01 Mar 2021 14:05:37 -0500 X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 42920@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1614625570; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post; bh=PPeHai1a3TxBBuOo0aVpeA7X6+PbTjT5YaCFLwVMGgU=; b=jqHvvLWZcbzmt7+QusM4jwk3kxiXhMQdA4mvzJB0i7hJ/E9dRHLB7+pnDtNBYqcEOyzMHv KzK+6I/ohA+toC6GJzEF2/BRbJfKyz7HBEBvTe8Y81U2R830AYK6+HtQQvLRT2N+wKpL7E +7dmemBztHqn3MhZGe7wHzOFwGg5r7fIRuBZkCPmLfYFhJTdqDJIZ/CLeZBa4ZitS7CXpA fHXfAx0z86nHwd/bRU2AnE+UXyZSpGZ4noWEI3gVDUwhPSTF5C3/Bnjc1jt3OU0PaaAsoc Pvc/O2FPP04lIvSLt4XP4pozmdCp5aWF/HYTVCRrH+bSTtaa05jyJJGS0eFyRA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614625570; a=rsa-sha256; cv=none; b=XAc+W7aBr8NkaWE1mXAFSyem7YfEdc3Gelj8y0ATQ+XG/MDsYWfKTz7MSHL4S0oempZWkL VE9t92yNOXXJ1LbVqfv9FGLkHEDiWoFYRLXStM1Tq+qS8nWd4H/PT58wpj3Lam+t9dTs4C SWvl8jJ7Dcvz9VuPc8XymQj7jiV0DeE5lc6JY9pjMk/5HSihwcdwCEuBdCkQqgcB95XcPo CQsQEeNBc4Hm2yVO+nHBJzRZ2t1bT9WZPjo8+ycgsGJTyA0qXhDf1oBMdufL3l3zCWONxm a9tRy35xucuGaUpMkNGXVeQxjlbHf4xNcSBF8OrhSDqki4DCvH63z3Fa2r7h/A== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=none; spf=pass (aspmx2.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Spam-Score: -2.37 Authentication-Results: aspmx2.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx2.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: E5290112A9 X-Spam-Score: -2.37 X-Migadu-Scanner: scn0.migadu.com X-TUID: xQ3p+CuX6Ntl --0000000000003a0e4905bc7e17c8 Content-Type: text/plain; charset="UTF-8" Hi Ricardo et al., I've not yet looked into updating the conda package, but want to add a small thing to the bug report, so it can easily be found. Lines in the sourced conda.sh script like the one below won't work anymore once the conda executable is wrapped in the guix shell script, because PS1 is eaten by the wrapper: "$CONDA_EXE" $_CE_M $_CE_CONDA It is necessary to explicitly call bash in interactive mode to have PS1 available: bash --norc -i "$CONDA_EXE" $_CE_M $_CE_CONDA However, that will add every executed line to the .bash_history file, including very long "export PYTHONPATH" lines. This can be avoided by explicitly setting the history file to nothing: HISTFILE= bash --norc -i "$CONDA_EXE" $_CE_M $_CE_CONDA Cheers, Hugo On Tue, 25 Aug 2020 at 17:03, Hugo Buddelmeijer wrote: > 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 > > --0000000000003a0e4905bc7e17c8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Ricardo et al.,

I've = not yet looked into updating the conda package, but want to add a small thi= ng to the bug report, so it can easily be found.

Lines in the sourced conda.sh script like the one below won't work a= nymore once the conda executable is wrapped in the guix shell script, becau= se PS1 is eaten by the wrapper:

=C2=A0=C2=A0= =C2=A0 "$CONDA_EXE" $_CE_M $_CE_CONDA

<= div>It is necessary to explicitly call bash in interactive mode to have PS1= available:

=C2=A0=C2=A0=C2=A0 bash --norc -i "$CONDA_EXE" $_CE_M $_CE_CONDA

However, that will add every executed line to= the .bash_history file, including very long "export PYTHONPATH" = lines. This can be avoided by explicitly setting the history file to nothin= g:

=C2=A0=C2=A0=C2=A0 HISTFILE=3D ba= sh --norc -i "$CONDA_EXE" $_CE_M = $_CE_CONDA

Cheers,
Hugo
<= /div>


On Tue, 25 Aug 2020 at 17:03, Hugo Buddelmeijer <hugo@buddelmeijer.nl> wrote:
<= div>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 prefixe= s some environment variables and appends the activation of the base environ= ment.

Now if we replace all 5 occurances of
<= div>"$CONDA_EXE" $_CE_M $_CE_CONDA
in that file with
bash --norc -i "$CONDA_EXE" $_CE_M $_CE_CONDA
t= hen everything works as expected.

The -i is to ena= ble interactive mode, preventing PS1 from being eaten. --norc is necessary = to not source .bashrc.
There are two occurences of "$CON= DA_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 si= mple sed replace on a single file. It is a bit hackish, because it adds kno= wledge to the package that a) there is a wrapper script and b) it is in bas= h.

I have only experimented with it by copyi= ng the output off `conda shell.bash hook` to a file in my home directory an= d editing that. Maybe I can try to update the package too.
Other options:
- Use some other sh than bash, one th= at does not eat PS1, (e.g. dash) as wrapper script. I just verified that *a= ll* 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 `c= onda init` such that
- it doesn't complain when it cannot edi= t files
- it only uses paths in ~/.guix-profile
but thi= s is not essential to get conda to work.

Cheer= s,
Hugo

--0000000000003a0e4905bc7e17c8--