Subject: Re: bug#77214: `guix pull` fails with `autocrlf=true` in git config

From: Simon Tournier <[email-masked]>
Date: Fri, 11 Apr 2025 19:14:17 +0200

Hi,

On Sun, 23 Mar 2025 at 12:36, Jodi Jodingtonstinski <[email-masked]> wrote:

> Ideally `guix pull` would ignore this setting (and possibly all user git
> settings?) if it does not work with it.
>  This causes errors such as:
>  `gnu/packages/music.scm:2732:1: invalid character in escape sequence:
> #\return`
> and can be resolved by disabling autocrlf and deleting
> `~/.cache/guix/checkouts` (thanks Rutherther)

For instance, using 1d846b89ca3:

--8<---------------cut here---------------start------------->8---
$ cat -n gnu/packages/music.scm | grep -C2 2732
  2730	          (add-after 'unpack 'patch-paths
  2731	            (lambda* (#:key inputs #:allow-other-keys)
  2732	              (substitute* "deps/juce/extras/Projucer/Source/ProjectSaving/\
  2733	jucer_ProjectExport_CodeBlocks.h"
  2734	                (("/usr/include/freetype2")
--8<---------------cut here---------------end--------------->8---

and I do not spot where the problem could come from.  But indeed,

--8<---------------cut here---------------start------------->8---
$ git config --global core.autocrlf true

$ guix pull --commit=1d846b8 -p /tmp/new
Updating channel 'guix' from Git repository at 'https://git.savannah.gnu.org/git/guix.git'...
Building from this channel:
  guix      https://git.savannah.gnu.org/git/guix.git	1d846b8
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'...   0.0%guix substitute: warning: bordeaux.guix.gnu.org: connection failed: Connection refused
substitute: 
substitute: updating substitutes from 'https://guix.bordeaux.inria.fr'... 100.0%
building /gnu/store/rc93f52y5l9v72l23cxzagq59mhhkc81-compute-guix-derivation.drv...
Computing Guix derivation for 'x86_64-linux'... \ice-9/read.scm:126:4: In procedure read-string:
gnu/packages/terminals.scm:601:1: invalid character in escape sequence: #\return
guix pull: error: You found a bug: the program '/gnu/store/08c4v80na6c6cpd3k159k0gfwf7ad1ap-compute-guix-derivation'
failed to compute the derivation for Guix (version: "1d846b89ca3100fb1c6387dfea3e052e9495cf55"; system: "x86_64-linux";
host version: "76e07a6f5c07f2c904ba5c1ade84feac88200ade"; pull-version: 1).
Please report the COMPLETE output above by email to <[email-masked]>.
--8<---------------cut here---------------end--------------->8---

And for me, the escape issue is elsewhere:

--8<---------------cut here---------------start------------->8---
$ cat -n gnu/packages/terminals.scm | grep -C2 ' 601'
   599	                                      "/etc/udev/rules.d/70-pcspkr-beep.rules")
   600	                     (lambda _
   601	                       (display (string-append "\
   602	ACTION==\"add\", SUBSYSTEM==\"input\", ATTRS{name}==\"PC Speaker\", "
   603	                                               "ENV{DEVNAME}!=\"\", "
--8<---------------cut here---------------end--------------->8---

Well, interesting! :-)

BTW, I agree with:

        > Ideally `guix pull` would ignore this setting (and possibly all user git
        > settings?)

and I’m even surprised that ~/.gitconfig is read by “guix pull”.  Ah?!

I do not know which libgit2 procedure via guile-git reads ~/.gitconfig;
somehow:

    openable-repository? relies on git_repository_open_ext

    -> obtain_config_and_set_oid_type
    -> git_repository_config_snapshot
    -> git_repository_config__weakptr

      and there I guess some GIT_CONFIG_FILENAME_* variables is read.

Well, that’s annoying.  I hope I’m missing something.

Cheers,
simon