Subject: Re: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing.

From: Ludovic Courtès <[email-masked]>
Date: Sun, 09 Feb 2025 12:28:55 +0100

Hi,

Noé Lopez <[email-masked]> skribis:

> --- a/gnu/packages.scm
> +++ b/gnu/packages.scm
> @@ -167,11 +167,12 @@ (define %patch-path
>    ;; Define it after '%package-module-path' so that '%load-path' contains user
>    ;; directories, allowing patches in $GUIX_PACKAGE_PATH to be found.
>    (make-parameter
> -   (map (lambda (directory)
> -          (if (string=? directory %distro-root-directory)
> -              (string-append directory "/gnu/packages/patches")
> -              directory))
> -        %load-path)))
> +   (let ((root (try-canonicalize-path %distro-root-directory)))
> +     (map (lambda (directory)
> +            (if (string=? (try-canonicalize-path directory) root)
> +                (string-append directory "/gnu/packages/patches")
> +                directory))
> +          %load-path))))

I’m not sure what the goal is but please keep in mind that
‘canonicalize-path’ is expensive in terms of system calls (especially if
‘%load-path’ is long, and we’d pay it for all program startup times),
and that the comparison here remains brittle (checking the dev/ino
fields of ‘stat’ would be more accurate).

Thanks,
Ludo’.