From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:38456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUcBA-00033p-OP for guix-patches@gnu.org; Sat, 25 May 2019 15:18:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUcB9-0000St-M5 for guix-patches@gnu.org; Sat, 25 May 2019 15:18:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36120) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hUcB7-0000R0-Vx for guix-patches@gnu.org; Sat, 25 May 2019 15:18:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hUcB7-0008AU-PI for guix-patches@gnu.org; Sat, 25 May 2019 15:18:01 -0400 Subject: [bug#35905] [PATCH] find-package-by-name: reverse package load precedence Resent-Message-ID: Received: from eggs.gnu.org ([209.51.188.92]:38304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUcA8-0002vB-SW for guix-patches@gnu.org; Sat, 25 May 2019 15:17:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUcA6-0007iB-Tl for guix-patches@gnu.org; Sat, 25 May 2019 15:17:00 -0400 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]:24264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hUcA5-0007XG-42 for guix-patches@gnu.org; Sat, 25 May 2019 15:16:58 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id E1A364FF6D for ; Sat, 25 May 2019 21:16:51 +0200 (CEST) Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id xvNc7L_6V_Ae for ; Sat, 25 May 2019 21:16:35 +0200 (CEST) From: Robert Vollmert Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Message-Id: Date: Sat, 25 May 2019 21:16:34 +0200 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 35905@debbugs.gnu.org =46rom e484a11fa652c6e9cb4484c6f700b91f134e7156 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sat, 25 May 2019 08:40:38 +0200 Subject: [PATCH] guix: find-package-by-name: list modules in path order A particular effect of this is that if there are ambiguous packages in a directory specified with `-L module_dir` and the distribution, the version from `module_dir` will be loaded, which is usually what would be expected. (E.g. for `guix build` or `guix package -i`.) * guix/discovery.scm (all-modules): Return modules in path order. * tests/guix-package.sh: Test local definitions take precedence. --- guix/discovery.scm | 4 ++-- tests/guix-package.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/guix/discovery.scm b/guix/discovery.scm index ef5ae73973..5bb494941b 100644 --- a/guix/discovery.scm +++ b/guix/discovery.scm @@ -145,8 +145,8 @@ Call (PROC MODULE RESULT) for each module that is = found." "Return the list of package modules found in PATH, a list of = directories to search. Entries in PATH can be directory names (strings) or (DIRECTORY . SUB-DIRECTORY) pairs, in which case modules are searched for beneath -SUB-DIRECTORY." - (fold-modules cons '() path #:warn warn)) +SUB-DIRECTORY. Modules are listed in the order they appear on the = path." + (reverse (fold-modules cons '() path #:warn warn))) =20 (define (fold-module-public-variables* proc init modules) "Call (PROC MODULE SYMBOL VARIABLE) for each variable exported by one = of MODULES, diff --git a/tests/guix-package.sh b/tests/guix-package.sh index 767c3f8a66..79d6ec65e4 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -280,6 +280,20 @@ export GUIX_PACKAGE_PATH guix package -A emacs-foo-bar | grep 42 guix package -i emacs-foo-bar@42 -n =20 +# Make sure GUIX_PACKAGE_PATH/'-L' takes precedence in case of = duplicate packages. +cat > "$module_dir/bar.scm"<&1 | grep choosing.*bar.scm +( unset GUIX_PACKAGE_PATH; \ + guix package -i hello -n -L "$module_dir" 2>&1 | grep = choosing.*bar.scm ) + # Make sure patches that live under $GUIX_PACKAGE_PATH are found. cat > "$module_dir/emacs.patch"<