GNU bug report logs - #76143
[PATCH] gnu: Canonicalize paths before comparing.

Previous Next

Package: guix-patches;

Reported by: Noé Lopez <noe <at> xn--no-cja.eu>

Date: Sat, 8 Feb 2025 13:37:01 UTC

Severity: normal

Tags: patch

Full log


Message #26 received at 76143 <at> debbugs.gnu.org (full text, mbox):

From: Noé Lopez <noe <at> xn--no-cja.eu>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, 76143 <at> debbugs.gnu.org,
 Christopher Baines <guix <at> cbaines.net>
Subject: Re: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing.
Date: Fri, 21 Feb 2025 16:42:07 +0100
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi,
>
> Noé Lopez <noe <at> noé.eu> skribis:
>
>> 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 don’t fully understand the situation.  My suggestion (but perhaps
> you’re already doing that) would be for PackageKit to invoke ‘guix
> repl’, not ‘guile’.  The raison d’être of ‘guix repl’ was precisely to
> have the load path for Guix and all its dependencies properly set up.
>

Let me try to explain the situation better:

The Guix channel has a special case for where it stores its patches, so
guix needs to detect whether a directory is the Guix source to append
"/gnu/packages/patches" to it:

gnu/packages.scm(166)
(define %patch-path
  (make-parameter
   (map (lambda (directory)
          (if (string=? directory %distro-root-directory)
              (string-append directory "/gnu/packages/patches")
              directory))
        %load-path)))

The comparison is done with string=?, which is a very weak way of
comparing directories, as you know.  But the directory list is supplied
by the environment, so its up to the user to set the path exactly equal
to %distro-root-directory.

Obviously, this can fail in many ways if the user is not using guix
through pre-inst-env or guix repl.  My patch fixes that by comparing
with stat, making sure all paths to the guix source work.

For PackageKit specifically, I am using guix through guile’s C api and
needed to set the environment by hand, I fixed it by removing the
trailing slash.

Is that clearer?

All the best,
Noé




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.