From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id JtagJZNuJmHobwAAgWs5BA (envelope-from ) for ; Wed, 25 Aug 2021 18:23:47 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id oFXVIJNuJmG9WAAA1q6Kng (envelope-from ) for ; Wed, 25 Aug 2021 16:23:47 +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 aspmx1.migadu.com (Postfix) with ESMTPS id 19F4829E36 for ; Wed, 25 Aug 2021 18:23:47 +0200 (CEST) Received: from localhost ([::1]:39202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIvgo-0002ff-5F for larch@yhetil.org; Wed, 25 Aug 2021 12:23:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIvge-0002fW-ML for guix-devel@gnu.org; Wed, 25 Aug 2021 12:23:36 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:44651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIvgb-0001d6-VU for guix-devel@gnu.org; Wed, 25 Aug 2021 12:23:36 -0400 Received: by mail-wr1-x431.google.com with SMTP id x12so109534wrr.11 for ; Wed, 25 Aug 2021 09:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=Fj3dD/b404bntCZF+nNctK/DbOjqf1bObrxXjbN0hVI=; b=saDowP9XTAowUCg2Q6Ye2INwijpcflRzjO29Oz4AXxpPDo5dsXkFhR1fovedpNtxra 8t4qZSBnWQoKSUxrNiO1ztB+PSulWNbo8YA4obQQMs0/CpeUbAcQ3b2/sW0yUhraoYSm QDnDppsKlNfov5BuOQnbfKtg9AfyCJiFqBa2bszBD+F5qEreyBzW5fes5s5I7PlMdT1C FTkFg3D/gVURcYliXPCyjNC4XFxd2efEscSFDO/wtOI4tbj+lbK88vAsIoQMB/eGEa7U eBtl1w6OaaBsQLXcgKtNgtWOioITQURvn3W6OffYHru+CcoYrLWaJNdx7Mbxchb0zZHm QSOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=Fj3dD/b404bntCZF+nNctK/DbOjqf1bObrxXjbN0hVI=; b=XOh2wlEagzmcaEJIJnCJW5uwra7lDQqse0bP+XLQ7Zh3NJnPQ7OsPi/hccV73YwIRH 4OQGkghsSeffMXq9qgHijjewxhB3DW30aJkbfIalUpBnvpWdDKumRarJUMfae9DcS0iO 1eHBOoSh2P8LUMa1qJQyswO5typ+8/fr4m+OZaioMP3OzVIanVTt12s9jwhxbPrx5tpM A3xM0gS42Dp2aQS+D2G9VHRyxi3I0h0KNj5vejwM5E7qHg1RhjtqNCt0BNEauLWK9vK5 PchqM8iNh15cFXLUC5/Kr5oWOEtIIzF4MVxnt0RdrpvknJycx9KFpXsxYXpHsnyIV1gy mY+w== X-Gm-Message-State: AOAM533aMkkAfuREw0/sIdfqo7dSMigXGQBJiQ1Wb5BHRDitEOFwLwls WtBqJCBtcybKdiZLYT/5Hed1HTSUHCDo8g== X-Google-Smtp-Source: ABdhPJwMPjaBelpDcfBpGGsfDphfwBmTH33hBAv8lBHEwT605pbPhhsdN5gKvkFikXbJGTyMiNTPzw== X-Received: by 2002:adf:ebcd:: with SMTP id v13mr26276678wrn.400.1629908612103; Wed, 25 Aug 2021 09:23:32 -0700 (PDT) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id a10sm5582034wmj.44.2021.08.25.09.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 09:23:31 -0700 (PDT) From: zimoun To: Ryan Prior , "guix-devel@gnu.org" Subject: Re: Transform options should error on nonexistant targets In-Reply-To: References: Date: Wed, 25 Aug 2021 18:16:56 +0200 Message-ID: <86pmu1qz2f.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=zimon.toutoune@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1629908627; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Fj3dD/b404bntCZF+nNctK/DbOjqf1bObrxXjbN0hVI=; b=kX4ux1yPc35Be33tKeS0oeldcqg6iPgR+jpUJk0YnKwugDVwLWuTlV3VxDzX4LO+kVKjwU akrWOpk2yXk2ERqjRdx1qhdDwLK/iEmtX/jKd8cnIYj3WWHMapLuL3zNCXqC6L6lPBTiWk lHT1IesNCGfoKcc4cqBqCoKEBY2fx2HMCqPXEQcnm2rdxTCcHw+hfTC0GyHtJ9+YXXGvks kb9EQKPPg8A2AEWL0JJ4omFWECLMa8uVVTc1tuqfmDyxwLWCG+3TwL55CpBwu6Fd3FM3bR I/5NNvCTEpTW0nXlAR+gvOtOcGwdeIpJ5VyY3jr1aNOLwxu62ss0hvbWLWzeHA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1629908627; a=rsa-sha256; cv=none; b=Br+oTkjAJZXv3Dd9pUR9W39x+adm5JCRQw5hBj0t+LfRWR6SLCMTbZii33wjqBOWvbgemt LMnER7Ymaqf706dFjgBmKvBaW14gqqBjOYOFR09xVtLUvLGWyTB9ELLvpBaYVwSb69f3mi 1GaS1QzDx8m5C2tUt6T76FdqIClMc27VXZbqXBkyiViJ1NVxVU1gTHkxYsSWZfYuMKXlH4 W7FeXucpwThBqyn0nu47dfRyNELLTjVfe/lZ+9JDXCsnNLwu7bsMEqbYZRCibtUhntXDoA K/QKW0f8jA98GfdQIC/53xRP0rO6i/XaJ0UD7siV7cOkofGU+sGlkclNYM+goA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=saDowP9X; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Spam-Score: -1.62 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=saDowP9X; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 19F4829E36 X-Spam-Score: -1.62 X-Migadu-Scanner: scn0.migadu.com X-TUID: FRKVLEJLuF6q --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ryan, On Wed, 18 Aug 2021 at 03:57, Ryan Prior wrote: > I learned today that Guix will chug happily along applying a transform to= a nonexistent package. > > For example, I can run: > guix environment --with-latest=3Dnot-exist --ad-hoc which > > This shows no warning or errors. I think it would be beneficial to show a= n error & bail if the target of a transformation is a package that doesn't = exist, as this is likely indicative of an error. Indeed. :-) The issue comes from guix/transformations.scm (options->transf= ormation): --8<---------------cut here---------------start------------->8--- (let ((new (transform obj))) (when (eq? new obj) (warning (G_ "transformation '~a' had no effect on ~a~%") name (if (package? obj) (package-full-name obj) obj))) new) --8<---------------cut here---------------end--------------->8--- and the warning is not reach because guix/packages.scm (package-mapping): --8<---------------cut here---------------start------------->8--- (else ;; Return a variant of P with PROC applied to P and its explic= it ;; dependencies, recursively. Memoize the transformations. F= ailing ;; to do that, we would build a huge object graph with lots of ;; duplicates, which in turns prevents us from benefiting from ;; memoization in 'package-derivation'. (let ((p (proc p))) (package =E2=80=A6 --8<---------------cut here---------------end--------------->8--- In the case of =E2=80=9Cguix build hello --with-latest=3Dfoo=E2=80=9D, then= =E2=80=99proc=E2=80=99 has no effect, i.e., =E2=80=99p=E2=80=99 is identical to =E2=80=99(proc p)=E2=80= =99 but a new package is allocated which leads that =E2=80=99new=E2=80=99 and =E2=80=99obj=E2=80=99 = are not =E2=80=99eq?=E2=80=99. Well, I have tried the attached patch. But then =E2=80=99tests/packages.sc= m=E2=80=99 fails. Hum, I need an input because I do not know if I miss something or if the test is also inaccurate. --8<---------------cut here---------------start------------->8--- (test-assert "package-input-rewriting/spec" (let* ((dep (dummy-package "chbouib" (native-inputs `(("x" ,grep))))) (p0 (dummy-package "example" (inputs `(("foo" ,coreutils) ("bar" ,grep) ("baz" ,dep))))) (rewrite (package-input-rewriting/spec `(("coreutils" . ,(const sed)) ("grep" . ,(const findutils))) #:deep? #f)) (p1 (rewrite p0)) (p2 (rewrite p0))) (and (not (eq? p1 p0)) (eq? p1 p2) ;memoization --8<---------------cut here---------------end--------------->8--- I miss why =E2=80=99p1=E2=80=99 should not be the same as =E2=80=99p0=E2=80= =99. > What do you think? Maybe, it could be worth to open a report for that. Feel free. ;-) Cheers, simon --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-packages-package-mapping-does-not-allocate-unwritten.patch Content-Transfer-Encoding: quoted-printable Content-Description: patch.patch >From e1cd54f4cccad37f7134b342c8dee9da9fa28588 Mon Sep 17 00:00:00 2001 From: zimoun Date: Wed, 25 Aug 2021 17:32:58 +0200 Subject: [PATCH 1/1] packages: 'package-mapping' does not allocate unwritten package. Reported by Ryan Prior . * guix/packages.scm (package-mapping): Do not allocate a new package if the procedure has no effect. --- guix/packages.scm | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index c825f427d8..15aa67fe0a 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -6,6 +6,7 @@ ;;; Copyright =C2=A9 2017, 2019, 2020 Efraim Flashner ;;; Copyright =C2=A9 2019 Marius Bakke ;;; Copyright =C2=A9 2021 Chris Marusich +;;; Copyright =C2=A9 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -1058,20 +1059,22 @@ applied to implicit inputs as well." ;; to do that, we would build a huge object graph with lots of ;; duplicates, which in turns prevents us from benefiting from ;; memoization in 'package-derivation'. - (let ((p (proc p))) - (package - (inherit p) - (location (package-location p)) - (build-system (if deep? - (build-system-with-package-mapping - (package-build-system p) rewrite) - (package-build-system p))) - (inputs (map rewrite (package-inputs p))) - (native-inputs (map rewrite (package-native-inputs p))) - (propagated-inputs (map rewrite (package-propagated-input= s p))) - (replacement (and=3D> (package-replacement p) replace)) - (properties `((,mapping-property . #t) - ,@(package-properties p))))))))) + (let ((new (proc p))) + (if (eq? new p) + p + (package + (inherit new) + (location (package-location new)) + (build-system (if deep? + (build-system-with-package-mapping + (package-build-system new) rewrite) + (package-build-system new))) + (inputs (map rewrite (package-inputs new))) + (native-inputs (map rewrite (package-native-inputs ne= w))) + (propagated-inputs (map rewrite (package-propagated-i= nputs new))) + (replacement (and=3D> (package-replacement new) repla= ce)) + (properties `((,mapping-property . #t) + ,@(package-properties new)))))))))) =20 replace) =20 --=20 2.32.0 --=-=-=--