GNU bug report logs -
#76143
[PATCH] gnu: Canonicalize paths before comparing.
Previous Next
Full log
Message #14 received at 76143 <at> debbugs.gnu.org (full text, mbox):
Ludovic Courtès <ludo <at> gnu.org> writes:
> Hi,
>
> Noé Lopez <noe <at> noé.eu> 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’.
I was not aware that you could do that with stat, I’ve sent a v2 that
uses stat for comparison which works much better.
The problem I faced was that I needed to create environment variables by
hand so that I could load guile code (including guix’s) in a C program
with no external environment (the packagekit daemon). It would fail
because of not finding patches since I had a trailing slash in my path.
I’ve resolved the issue by removing the slash, but I wanted to fix it
for everyone else trying to use Guix as a library.
This bug report was last modified 118 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.