GNU logs - #76376, boring messages


Message sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#76376] [PATCH] guix: gexp: canonicalize file paths for import
Resent-From: Ryan Sundberg <ryan@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Mon, 17 Feb 2025 22:00:02 +0000
Resent-Message-ID: <handler.76376.B.173982956611601 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 76376
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 76376 <at> debbugs.gnu.org
Cc: Ryan Sundberg <ryan@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-To: guix-patches@HIDDEN
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.173982956611601
          (code B ref -1); Mon, 17 Feb 2025 22:00:02 +0000
Received: (at submit) by debbugs.gnu.org; 17 Feb 2025 21:59:26 +0000
Received: from localhost ([127.0.0.1]:50460 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tk99C-000310-6D
	for submit <at> debbugs.gnu.org; Mon, 17 Feb 2025 16:59:26 -0500
Received: from lists.gnu.org ([2001:470:142::17]:36440)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ryan@HIDDEN>) id 1tk994-0002zz-BJ
 for submit <at> debbugs.gnu.org; Mon, 17 Feb 2025 16:59:19 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ryan@HIDDEN>) id 1tk98y-0003nY-RQ
 for guix-patches@HIDDEN; Mon, 17 Feb 2025 16:59:12 -0500
Received: from mail.arctype.co ([138.68.9.245])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <ryan@HIDDEN>) id 1tk98w-0002G2-Id
 for guix-patches@HIDDEN; Mon, 17 Feb 2025 16:59:12 -0500
Received: from authenticated-user (mail.arctype.co [138.68.9.245])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.arctype.co (Postfix) with ESMTPSA id 94FCC13B3B6;
 Mon, 17 Feb 2025 21:58:55 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=arctype.co; s=mail;
 t=1739829535; bh=vKdpgzDvEqBWHS27E/U7tzuRVcQnsZqymzUUgd8zWo4=;
 h=From:To:Cc:Subject:Date:From;
 b=qNe77IicaLsunoHx7ZwbQgz+aa7VmV0xeTtEmwP2wabbn0Zu8Fi0A5CK5bdrYDbjL
 RDI0BCW6tUI1eQ6d7ZIaC+HCaPq4S46SZcbf9QXS8/bu7BYfZgmeyOjyx9pA9vbK2u
 AZVESw4i6CZN3vIduxINwGpWYPbWxpb+/VGEo9NmYhAL2B90IKnDoKDkOJRaqMtLyt
 PVcg+Ir8WJ34OILI6wW3btDs8rVOvgOsKtkKIDrQfvetE/FF9oITHY1BdLe6vvumaS
 DtCgniWZWljU7P6ZUb9FWbIZOj8CylED9S4YR2yOPTYGP7WtvcBUaCg7qpO1l8nCh0
 F7namNiBdCKTg==
From: Ryan Sundberg <ryan@HIDDEN>
Date: Mon, 17 Feb 2025 13:58:44 -0800
Message-ID: <0dafbea136e328cd214e7e1fb05ab91ab04b17da.1739829485.git.ryan@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=138.68.9.245; envelope-from=ryan@HIDDEN;
 helo=mail.arctype.co
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,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

When we intern a file from the store during `imported-modules`, if the
file is a symlink (e.g., from a Guix profile), a dangling symlink can be
created in the module-import builder.

Follow any symlinks before interning the files to the store, so that the
file itself is imported and not the dangling link.

See also: https://issues.guix.gnu.org/73275

* guix/gexp.scm (imported-files/derivation): canonicalize-path

Change-Id: Ic0af90cda7c5c5819526e455cf62300e18408dbd
---
 guix/gexp.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index e44aea6420..85351b0322 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1576,7 +1576,7 @@ (define* (imported-files/derivation files
   (define file-pair
     (match-lambda
      ((final-path . (? string? file-name))
-      (mlet %store-monad ((file (interned-file file-name
+      (mlet %store-monad ((file (interned-file (canonicalize-path file-name)
                                                (basename final-path))))
         (return (list final-path file))))
      ((final-path . file-like)

base-commit: 91b18baa4274a025d28f06133682a9269217730d
-- 
2.41.0





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Ryan Sundberg <ryan@HIDDEN>
Subject: bug#76376: Acknowledgement ([PATCH] guix: gexp: canonicalize file
 paths for import)
Message-ID: <handler.76376.B.173982956611601.ack <at> debbugs.gnu.org>
References: <0dafbea136e328cd214e7e1fb05ab91ab04b17da.1739829485.git.ryan@HIDDEN>
X-Gnu-PR-Message: ack 76376
X-Gnu-PR-Package: guix-patches
X-Gnu-PR-Keywords: patch
Reply-To: 76376 <at> debbugs.gnu.org
Date: Mon, 17 Feb 2025 22:00:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

As you requested using X-Debbugs-CC, your message was also forwarded to
  Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>,=
 Ludovic Court=C3=A8s <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, =
Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@tobias=
.gr>
(after having been given a bug report number, if it did not have one).

Your message has been sent to the package maintainer(s):
 guix-patches@HIDDEN

If you wish to submit further information on this problem, please
send it to 76376 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
76376: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D76376
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#76376] Additional context for #76376 - gexp / canonicalize-path
References: <0dafbea136e328cd214e7e1fb05ab91ab04b17da.1739829485.git.ryan@HIDDEN>
In-Reply-To: <0dafbea136e328cd214e7e1fb05ab91ab04b17da.1739829485.git.ryan@HIDDEN>
Resent-From: Ryan Sundberg <ryan@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Mon, 17 Feb 2025 22:19:02 +0000
Resent-Message-ID: <handler.76376.B76376.173983072629878 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 76376
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 76376 <at> debbugs.gnu.org
Received: via spool by 76376-submit <at> debbugs.gnu.org id=B76376.173983072629878
          (code B ref 76376); Mon, 17 Feb 2025 22:19:02 +0000
Received: (at 76376) by debbugs.gnu.org; 17 Feb 2025 22:18:46 +0000
Received: from localhost ([127.0.0.1]:50600 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tk9Rt-0007lo-RC
	for submit <at> debbugs.gnu.org; Mon, 17 Feb 2025 17:18:46 -0500
Received: from mail.arctype.co ([138.68.9.245]:50055)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <ryan@HIDDEN>) id 1tk9Rq-0007l8-N6
 for 76376 <at> debbugs.gnu.org; Mon, 17 Feb 2025 17:18:43 -0500
Received: from authenticated-user (mail.arctype.co [138.68.9.245])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by mail.arctype.co (Postfix) with ESMTPSA id A5F0B13B17F
 for <76376 <at> debbugs.gnu.org>; Mon, 17 Feb 2025 22:18:05 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=arctype.co; s=mail;
 t=1739830685; bh=Z+nV1P1yxH6YCGKYsmeGhSAq8ngzDO+ae0XslTso6Mc=;
 h=Date:To:From:Subject:From;
 b=hCees22OseckGq8yRqXxKAPYJuPwSfuUeifekM0VAETKbm4RhNbwYYOZlDz5Psh4r
 JDeQIvWvOI3Gp2E4p81jP+pIRwnHdrkbjkOLvmsbYNjREVva1DAZnLBaFRM7qXRc1v
 motA3kaxQE9htHkMzA99H1VfO24B49GiLqbJKDSwrtw031axa/q8S5wYXzjMJBTsDZ
 kf8lgY7FGF/Zi/VdxlHp5w/191mtwsc+Kj34tXD3tqbXllPQi/ViX9L/e86h3R5BwB
 7LKXEBgLnbZNucfBRRv03b+oNaGcH07TV/2bgwpVadLd5u+6iIqj1iJzlwi6cIUzRp
 nsuk4lLYfAs9g==
Message-ID: <8155d903-bfd1-447d-b639-c98018a19119@HIDDEN>
Date: Mon, 17 Feb 2025 14:18:05 -0800
MIME-Version: 1.0
Content-Language: en-US
From: Ryan Sundberg <ryan@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello team,

This is a patch for a "deep" bug in Guix gexp processing which evokes in 
circumstances when using g-expressions to build things that try to 
create module closures with code that is referenced in the current 
environment via symlink.

It can manifest in difficult to comprehend errors, such as "no code for 
module: (guix utils)` when guix/utils.scm is correctly defined in the 
load path of the program and exists (but it is a symlink, such as by 
using `guix shell` to load another guix environment, e.g. where the 
shell imports a different guix itself).

In my use case, I was using `guix` to build raw os disk images with my 
own set of customized packages and services when this bug blocked me at 
a dead stop.

The root cause of this after much complex debugging, tracing, and 
reading helped me to identify the bug report from Ludo at 
https://issues.guix.gnu.org/73275 and understand the dangling symlink 
issue. What happens here, and what this patch fixes, is that the 
`interned-file` procedure will not follow symlinks, and will intern a 
symlink if it is told to. In most scenarios this is harmless as the 
symlinks intersect to something (e.g. guix/utils.scm) which is already 
in the profile anyways, so the bug is dormant.
However, in other cases, it is possible to create a dangling symlink 
here when `imported-modules` references a file which is a symlink on the 
Guile %load-path, and `interned-file` in this line of gexp.scm can 
intern a dangling symlink.

This patch closes that possibility by canonicalizing the path of the 
interned file before loading it into the module closure path, so that 
`imported-modules` will never import a dangling symlink to a guile file 
used by a module-closure.

--Ryan






Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#76376] [PATCH] guix: gexp: canonicalize file paths for import
Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Fri, 21 Feb 2025 10:58:02 +0000
Resent-Message-ID: <handler.76376.B76376.17401354228554 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 76376
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Ryan Sundberg <ryan@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, 76376 <at> debbugs.gnu.org, Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN>
Received: via spool by 76376-submit <at> debbugs.gnu.org id=B76376.17401354228554
          (code B ref 76376); Fri, 21 Feb 2025 10:58:02 +0000
Received: (at 76376) by debbugs.gnu.org; 21 Feb 2025 10:57:02 +0000
Received: from localhost ([127.0.0.1]:54729 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tlQiL-0002Dh-Vv
	for submit <at> debbugs.gnu.org; Fri, 21 Feb 2025 05:57:02 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:54526)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1tlQiK-0002CY-BP
 for 76376 <at> debbugs.gnu.org; Fri, 21 Feb 2025 05:57:01 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1tlQiC-0003aV-VM; Fri, 21 Feb 2025 05:56:52 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=xv4MNlKLRm8M8tN/wUKKtvtyfmYpBGimUhdUuLK4V+Y=; b=lbwRiX5xy2Gz3wFUjv5l
 euoU9qVr4sX8bPff1J0ysGkOIIYTwosv08+C7Ho7qdQUFLWUrtuE8F57qxTdU97c6YUKA0tBD2KDp
 ZUISin4X0zvX5wPz4GFdCQiN0ET9nnuI8unOO89V6uBEB/5U6K47nY0M+wkHFAtxzf3yB7WXSrjlI
 Lc4uEnYsdvVEbxWrOJIwL26OxcsEn5ZKQCCEdFYVhZTpmva4YBeYAVJEme8qjeRznG3rRFmyCyf29
 XgRD3xm04s+zMC02e4dveBKUScH3JhW3xQBxqNlEZtyREFlM5bQn6tkex24Z+O1Bey4C/aASUxKXG
 oS2aFIaMqexyLA==;
From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
In-Reply-To: <0dafbea136e328cd214e7e1fb05ab91ab04b17da.1739829485.git.ryan@HIDDEN>
 (Ryan Sundberg's message of "Mon, 17 Feb 2025 13:58:44 -0800")
References: <0dafbea136e328cd214e7e1fb05ab91ab04b17da.1739829485.git.ryan@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: Tridi 3 =?UTF-8?Q?Vent=C3=B4se?= an 233 de la
 =?UTF-8?Q?R=C3=A9volution,?= jour du Violier
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Fri, 21 Feb 2025 11:56:48 +0100
Message-ID: <87v7t3a7m7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Ryan Sundberg <ryan@HIDDEN> skribis:

> When we intern a file from the store during `imported-modules`, if the
> file is a symlink (e.g., from a Guix profile), a dangling symlink can be
> created in the module-import builder.
>
> Follow any symlinks before interning the files to the store, so that the
> file itself is imported and not the dangling link.
>
> See also: https://issues.guix.gnu.org/73275
>
> * guix/gexp.scm (imported-files/derivation): canonicalize-path
>
> Change-Id: Ic0af90cda7c5c5819526e455cf62300e18408dbd

[...]

>       ((final-path . (? string? file-name))
> -      (mlet %store-monad ((file (interned-file file-name
> +      (mlet %store-monad ((file (interned-file (canonicalize-path file-n=
ame)
>                                                 (basename final-path))))

Instead of calling =E2=80=98canonicalize-path=E2=80=99, which leads to many=
 syscalls,
I=E2=80=99d suggest:

   (interned-file file-name (basename final-path)
                  #:recursive? #f)

I believe that would have the desired effect.

Could you also add a test that reproduces the problem?

Thanks,
Ludo=E2=80=99.




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#76376] [PATCH] guix: gexp: canonicalize file paths for import
Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Tue, 25 Feb 2025 15:09:02 +0000
Resent-Message-ID: <handler.76376.B76376.174049613316533 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 76376
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Ryan Sundberg <ryan@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, 76376 <at> debbugs.gnu.org, Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN>
Received: via spool by 76376-submit <at> debbugs.gnu.org id=B76376.174049613316533
          (code B ref 76376); Tue, 25 Feb 2025 15:09:02 +0000
Received: (at 76376) by debbugs.gnu.org; 25 Feb 2025 15:08:53 +0000
Received: from localhost ([127.0.0.1]:47928 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tmwYG-0004IY-Ki
	for submit <at> debbugs.gnu.org; Tue, 25 Feb 2025 10:08:53 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:59182)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1tmwYD-0004IE-EG
 for 76376 <at> debbugs.gnu.org; Tue, 25 Feb 2025 10:08:50 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1tmwY6-00049O-Tv; Tue, 25 Feb 2025 10:08:42 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=NqlmDkKXmd791dktd7JFRm1ptMsTAo1kd4b0n3SjG2Q=; b=YJNvn65/XTrImruSPkvv
 cYYyBqHDMtvpGGITGf8gPE3mTTgXc0tUXWlN+fLIanzi7PgTIkJU8aBeVJ5fv7Xg92G0b7vvy0Cwk
 gW1/xXB0a9lD9jRu68DVKgMe828bCLpk6FiL/lUgprPw0/BOlNcsZ3jZ5dmp5I7SomJNgsrf0+sYY
 1hnEQB5Uqbiv1/cTXbJr2Q4o87zgxIZXvG8DWNh+UVZ1NJXMEQ2mTgyLFL5KiNlpBcM2Iy6NhODu+
 dKJR8+BTx80083P6lCEfttHlo+p8y2VqbUVpCb4Eo4glXDp4WYFhyb5BIIfxiVuZFFYMY+jrH3xqV
 x/219N5bWksiuA==;
From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
In-Reply-To: <87v7t3a7m7.fsf@HIDDEN> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Fri, 21 Feb 2025 11:56:48 +0100")
References: <0dafbea136e328cd214e7e1fb05ab91ab04b17da.1739829485.git.ryan@HIDDEN>
 <87v7t3a7m7.fsf@HIDDEN>
Date: Tue, 25 Feb 2025 16:08:24 +0100
Message-ID: <87seo2njtj.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hello Ryan,

Ludovic Court=C3=A8s <ludo@HIDDEN> skribis:

>>       ((final-path . (? string? file-name))
>> -      (mlet %store-monad ((file (interned-file file-name
>> +      (mlet %store-monad ((file (interned-file (canonicalize-path file-=
name)
>>                                                 (basename final-path))))
>
> Instead of calling =E2=80=98canonicalize-path=E2=80=99, which leads to ma=
ny syscalls,
> I=E2=80=99d suggest:
>
>    (interned-file file-name (basename final-path)
>                   #:recursive? #f)

It was missing one bit; attached is an version of it that works.

I chose =E2=80=98readlink*=E2=80=99 because it=E2=80=99s less expensive that
=E2=80=98canonicalize-path=E2=80=99: only one extra syscall (readlink) when=
 =E2=80=98file-name=E2=80=99
is already a regular file.

For the record, I stumbled upon this bug just today while working on
<https://issues.guix.gnu.org/75810>: the "imported-files does not create
symlinks" in =E2=80=98tests/gexp.scm=E2=80=99 would fail when running in an=
 isolated
environment because file =E2=80=9Cx=E2=80=9D would be a symlink to a file o=
utside the
store.

Ludo=E2=80=99.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/guix/gexp.scm b/guix/gexp.scm
index ad51bc55b78..ddd2e1a0812 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1584,8 +1584,9 @@ (define* (imported-files/derivation files
   (define file-pair
     (match-lambda
      ((final-path . (? string? file-name))
-      (mlet %store-monad ((file (interned-file file-name
-                                               (basename final-path))))
+      (mlet %store-monad ((file (interned-file (readlink* file-name)
+                                               (basename final-path)
+                                               #:recursive? #f)))
         (return (list final-path file))))
      ((final-path . file-like)
       (mlet %store-monad ((file (lower-object file-like system)))

--=-=-=--




Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 28 Feb 2025 11:03:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 28 06:03:22 2025
Received: from localhost ([127.0.0.1]:45757 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tny9K-0003TG-At
	for submit <at> debbugs.gnu.org; Fri, 28 Feb 2025 06:03:22 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:49794)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1tny9I-0003Sw-60
 for control <at> debbugs.gnu.org; Fri, 28 Feb 2025 06:03:20 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>) id 1tny9C-0007e7-I4
 for control <at> debbugs.gnu.org; Fri, 28 Feb 2025 06:03:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:Subject:From:To:Date:in-reply-to:
 references; bh=wGUVj7JXShP+fJlAZFIBj2TrD53IIUsz1G0XZK+yqbE=; b=Qlkfa+Vw5nxBUb
 gUU2Y05ucTzkzskvk/u+tbWaic3kackxqXMiasVUUNhTPjmSoYfRXJe+dNlYKMh0ToLRNrWIOiYxc
 Ux6eTfPo7H5OhYoCHWJ6wE1K8c0GWo3UKxC0RJqkQXPQV8dEU4/9JqcEaaR9FftyehngDixJoyz0Y
 gPZ50sdIkvcq6U2Dn/911naMkwalE3Hc1HHrsThjK4xV5GKcZ8TzQiwOnE5Bgoo8w3WMBKtMmoOt/
 EUSdVpGHy5hQ9uM68JuINCXNVR9zOFD0PrUn/KuI3BdJSIYba2HlvJQeuxt4naZ2KmVuzb5WvOA3G
 jNL/tRDwSoRRQn0Y9DIg==;
Date: Fri, 28 Feb 2025 12:03:08 +0100
Message-Id: <87mse6tjpv.fsf@HIDDEN>
To: control <at> debbugs.gnu.org
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
Subject: control message for bug #75810
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

block 75810 by 76376
quit






Last modified: Fri, 28 Feb 2025 11:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.