GNU bug report logs - #77214
`guix pull` fails with `autocrlf=true` in git config

Previous Next

Package: guix;

Reported by: Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com>

Date: Sun, 23 Mar 2025 17:46:03 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 77214 in the body.
You can then email your comments to 77214 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#77214; Package guix. (Sun, 23 Mar 2025 17:46:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Sun, 23 Mar 2025 17:46:03 GMT) Full text and rfc822 format available.

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

From: Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com>
To: bug-guix <at> gnu.org
Subject: `guix pull` fails with `autocrlf=true` in git config
Date: Sun, 23 Mar 2025 12:36:25 -0500
[Message part 1 (text/plain, inline)]
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)
[Message part 2 (text/html, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#77214; Package guix. (Fri, 11 Apr 2025 17:16:03 GMT) Full text and rfc822 format available.

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

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com>, 77214 <at> debbugs.gnu.org
Subject: Re: bug#77214: `guix pull` fails with `autocrlf=true` in git config
Date: Fri, 11 Apr 2025 19:14:17 +0200
Hi,

On Sun, 23 Mar 2025 at 12:36, Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com> 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 <bug-guix <at> gnu.org>.
--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




Information forwarded to bug-guix <at> gnu.org:
bug#77214; Package guix. (Fri, 11 Apr 2025 19:49:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com>
Cc: 77214 <at> debbugs.gnu.org
Subject: Re: bug#77214: `guix pull` fails with `autocrlf=true` in git config
Date: Fri, 11 Apr 2025 21:47:51 +0200
[Message part 1 (text/plain, inline)]
Hello,

Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com> skribis:

> 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)

I agree that ‘guix pull’ should ignore such settings; even if errors
like the one above did not occur, you’d get a checkout that’s different
at the binary level, and so no substitutes etc.

I think the patch below should do that, at least for new checkouts.

It would be great if you could try it and check that it works for you.
You can do that by:

  rm -rf ~/.cache/guix/checkouts
  git config --global core.autocrlf true
  ./pre-inst-env guix download --git \
     https://git.savannah.gnu.org/git/shepherd.git
  
Although I’m not sure ‘autocrlf’ would fire on this repo (why does it
fire in the first place on the Git repo⁈).

Thanks,
Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/guix/git.scm b/guix/git.scm
index 4164531c0b..0a7bcea9bb 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe <at> gmail.com>
-;;; Copyright © 2018-2024 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2018-2025 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2021 Kyle Meyer <kyle <at> kyleam.com>
 ;;; Copyright © 2021 Marius Bakke <marius <at> gnu.org>
 ;;; Copyright © 2022 Maxime Devos <maximedevos <at> telenet.be>
@@ -236,10 +236,17 @@ (define* (clone* url directory #:key (verify-certificate? #t))
     (lambda ()
       (mkdir-p directory)
 
-      (clone url directory
-             (make-clone-options
-              #:fetch-options (make-default-fetch-options
-                               #:verify-certificate? verify-certificate?))))
+      (let* ((repository
+              (clone url directory
+                     (make-clone-options
+                      #:fetch-options (make-default-fetch-options
+                                       #:verify-certificate?
+                                       verify-certificate?))))
+             (config (repository-config repository)))
+        ;; Prevent modification of the raw data.
+        (set-config-string config "core.autocrlf" "input")
+
+        repository))
     (lambda _
       (false-if-exception (rmdir directory)))))
 

Information forwarded to bug-guix <at> gnu.org:
bug#77214; Package guix. (Sun, 13 Apr 2025 15:18:01 GMT) Full text and rfc822 format available.

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

From: Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 77214 <at> debbugs.gnu.org
Subject: Re: bug#77214: `guix pull` fails with `autocrlf=true` in git config
Date: Sun, 13 Apr 2025 10:17:16 -0500
[Message part 1 (text/plain, inline)]
>
> It would be great if you could try it and check that it works for you.
> You can do that by:
>
>   rm -rf ~/.cache/guix/checkouts
>   git config --global core.autocrlf true
>   ./pre-inst-env guix download --git \
>      https://git.savannah.gnu.org/git/shepherd.git

I did this and it worked!
I also checked if the downloaded files had any carriage return characters
and they did not, so AFAICT that guarantees autocrlf was ignored.
thank you for this patch, I wasn't able to figure it out myself.

(I had to temporarily use my web-mail client which does not reply-all by
default so I'm re-sending this message with reply-all, my bad)
[Message part 2 (text/html, inline)]

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Mon, 14 Apr 2025 21:10:02 GMT) Full text and rfc822 format available.

Notification sent to Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com>:
bug acknowledged by developer. (Mon, 14 Apr 2025 21:10:03 GMT) Full text and rfc822 format available.

Message #19 received at 77214-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com>
Cc: 77214-done <at> debbugs.gnu.org
Subject: Re: bug#77214: `guix pull` fails with `autocrlf=true` in git config
Date: Mon, 14 Apr 2025 23:09:43 +0200
Hi Jodi,

Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com> writes:

>  It would be great if you could try it and check that it works for you.
>  You can do that by:
>
>    rm -rf ~/.cache/guix/checkouts
>    git config --global core.autocrlf true
>    ./pre-inst-env guix download --git \
>       https://git.savannah.gnu.org/git/shepherd.git
>
> I did this and it worked!
> I also checked if the downloaded files had any carriage return characters and they did not, so AFAICT that guarantees autocrlf was
> ignored.
> thank you for this patch, I wasn't able to figure it out myself.

Pushed as b5e567bb2b277f89af493ba8cd0799fdb368a184.  Thanks for testing!

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#77214; Package guix. (Tue, 15 Apr 2025 16:17:01 GMT) Full text and rfc822 format available.

Message #22 received at 77214-done <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>, Jodi Jodingtonstinski
 <jodijodingtondev <at> gmail.com>
Cc: 77214-done <at> debbugs.gnu.org
Subject: Re: bug#77214: `guix pull` fails with `autocrlf=true` in git config
Date: Tue, 15 Apr 2025 18:15:48 +0200
[Message part 1 (text/plain, inline)]
Hi Ludo,

On Mon, 14 Apr 2025 at 23:09, Ludovic Courtès <ludo <at> gnu.org> wrote:

>>    rm -rf ~/.cache/guix/checkouts
>>    git config --global core.autocrlf true
>>    ./pre-inst-env guix download --git \
>>       https://git.savannah.gnu.org/git/shepherd.git

This test does not catch the scenario leading to buggy behaviour, IMHO.

> Pushed as b5e567bb2b277f89af493ba8cd0799fdb368a184.  Thanks for testing!

This fixes appears to me incorrect.  Because it only fixes on a fresh
clone, when the typical scenario appears to me:

 1. I run Guix since months or years, no problem. \o/
 2. I work on a project with some collaborators running Windows.
 3. I add a global Git config.
 4. I run “guix pull“.  Bang!

Example:

--8<---------------cut here---------------start------------->8---
$ /tmp/new/bin/guix describe
Generation 1	Apr 15 2025 15:30:39	(current)
  guix b5e567b
    repository URL: https://git.savannah.gnu.org/git/guix.git
    commit: b5e567bb2b277f89af493ba8cd0799fdb368a184

$ git config --global core.autocrlf true

$ /tmp/new/bin/guix pull -q -p /tmp/last
Updating channel 'guix' from Git repository at 'https://git.savannah.gnu.org/git/guix.git'...
Authenticating channel 'guix', commits 9edb3f6 to ec5ea23 (29 new commits)...
Building from this channel:
  guix      https://git.savannah.gnu.org/git/guix.git	ec5ea23
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
building /gnu/store/sggwz0vn6pldxnqfzgqaw4fx1rjkjwkj-config.scm.drv...
building /gnu/store/ybvdb767hk7ccilgmb3z4yl85xgw20sc-git.scm.drv...
building /gnu/store/fp8pld5b1b6sgbi9k1gwwrypynyi2n8g-hash.scm.drv...
applying 2 grafts for libffi-3.4.4 ...
applying 2 grafts for libgc-8.2.4 ...
applying 2 grafts for libunistring-1.1 ...
applying 2 grafts for pkg-config-0.29.2 ...
applying 7 grafts for guile-3.0.9 ...
building /gnu/store/c31lw8lmf2ncsbkpcqxwzzq01j1wb4ih-module-import.drv...
building /gnu/store/wdp91p4y3kcvjfrpq9das1na95qjlgnf-module-import.drv...
building /gnu/store/kvwl0ay9bb10fcibn96asnr73l4g2z4k-module-import-compiled.drv...
building /gnu/store/ify060g05i9rgxn15393yphnck775zb3-module-import-compiled.drv...
building /gnu/store/w89wb1k6139xj9k7ds4jqvzqx1qqc1b9-compute-guix-derivation.drv...
Computing Guix derivation for 'x86_64-linux'... /ice-9/read.scm:126:4: In procedure read-string:
gnu/packages/firmware.scm:1678:1: invalid character in escape sequence: #\return
guix pull: error: You found a bug: the program '/gnu/store/hqzmzshc0q3rbhcn2wpkm9xlf8sc6s8m-compute-guix-derivation'
failed to compute the derivation for Guix (version: "ec5ea239e9887f6ccf8aef0c9f9a6de9f72f7366"; system: "x86_64-linux";
host version: "b5e567bb2b277f89af493ba8cd0799fdb368a184"; pull-version: 1).
Please report the COMPLETE output above by email to <bug-guix <at> gnu.org>.
--8<---------------cut here---------------end--------------->8---

Well, I have not found a way to tell to libgit2 to ignore *any*
configuration file [1].  Therefore, your fix seems the easiest.

However, the fix should be inside ’update-cached-checkout’.  It should
not be inside ’clone*’ because a) it does not fix potential annoyances
when people already cloned the repository – see above – and b) the issue
isn’t from the generic cloning but from cache management.

See the attached patch.  WDYT?

Cheers,
simon

[0001-git-Move-core.autocrlf-settings.patch (text/x-diff, inline)]
From 2f2b1af5f2c87671be06660bb8d8b6d2c9c3f6dd Mon Sep 17 00:00:00 2001
Message-ID: <2f2b1af5f2c87671be06660bb8d8b6d2c9c3f6dd.1744733253.git.zimon.toutoune <at> gmail.com>
From: Simon Tournier <zimon.toutoune <at> gmail.com>
Date: Tue, 15 Apr 2025 17:57:00 +0200
Subject: [PATCH] =?UTF-8?q?git:=20Move=20=E2=80=98core.autocrlf=E2=80=99?=
 =?UTF-8?q?=20settings.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Follow up of b5e567bb2b277f89af493ba8cd0799fdb368a184.

* guix/git.scm (clone*): Move ‘core.autocrlf’ settings from here...
(update-cached-checkout): ...to here.

Change-Id: I0f91d348376f9953cfbc497148596b738705818b
---
 guix/git.scm | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/guix/git.scm b/guix/git.scm
index 01e09185885..3965c61ba0b 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -241,12 +241,7 @@ (define* (clone* url directory #:key (verify-certificate? #t))
                      (make-clone-options
                       #:fetch-options (make-default-fetch-options
                                        #:verify-certificate?
-                                       verify-certificate?))))
-             (config (repository-config repository)))
-        ;; Override 'core.autocrlf' as set in ~/.gitconfig to ensure files are
-        ;; left unchanged when cloning and pulling.
-        (set-config-string config "core.autocrlf" "input")
-
+                                       verify-certificate?)))))
         repository))
     (lambda _
       (false-if-exception (rmdir directory)))))
@@ -606,7 +601,12 @@ (define* (update-cached-checkout url
                              (repository-open cache-directory)
                              (clone/swh-fallback url ref cache-directory
                                                  #:verify-certificate?
-                                                 verify-certificate?))))
+                                                 verify-certificate?)))
+          (config (repository-config repository)))
+     ;; Override 'core.autocrlf' as set in ~/.gitconfig to ensure files are
+     ;; left unchanged when cloning and pulling.
+     (set-config-string config "core.autocrlf" "input")
+
      ;; Only fetch remote if it has not been cloned just before.
      (when (and cache-exists?
                 (not (reference-available? repository ref)))

base-commit: ec5ea239e9887f6ccf8aef0c9f9a6de9f72f7366
-- 
2.46.0

[Message part 3 (text/plain, inline)]

- - -
1: bug#77214: `guix pull` fails with `autocrlf=true` in git config
Simon Tournier <zimon.toutoune <at> gmail.com>
Fri, 11 Apr 2025 19:14:17 +0200
id:87mscmboye.fsf <at> gmail.com
https://issues.guix.gnu.org/77214
https://issues.guix.gnu.org/msgid/87mscmboye.fsf <at> gmail.com
https://yhetil.org/guix/87mscmboye.fsf <at> gmail.com

PS: From my understanding, this change does not deserve Copyright.  I
    know your optimistic idea: maybe you will change again and then
    maybe again this file, so then the Copyright applies. :-) I still
    think we should keep the “rule” of non-trivial change which means
    more or less 5+ lines modified.  For what my opinion is worth
    here. :-)

Information forwarded to bug-guix <at> gnu.org:
bug#77214; Package guix. (Tue, 15 Apr 2025 17:03:04 GMT) Full text and rfc822 format available.

Message #25 received at 77214-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Simon Tournier <zimon.toutoune <at> gmail.com>
Cc: Jodi Jodingtonstinski <jodijodingtondev <at> gmail.com>,
 77214-done <at> debbugs.gnu.org
Subject: Re: bug#77214: `guix pull` fails with `autocrlf=true` in git config
Date: Tue, 15 Apr 2025 18:39:06 +0200
Simon Tournier <zimon.toutoune <at> gmail.com> writes:

> This fixes appears to me incorrect.  Because it only fixes on a fresh
> clone,

Yes, but it’s a cache.

> From 2f2b1af5f2c87671be06660bb8d8b6d2c9c3f6dd Mon Sep 17 00:00:00 2001
> Message-ID: <2f2b1af5f2c87671be06660bb8d8b6d2c9c3f6dd.1744733253.git.zimon.toutoune <at> gmail.com>
> From: Simon Tournier <zimon.toutoune <at> gmail.com>
> Date: Tue, 15 Apr 2025 17:57:00 +0200
> Subject: [PATCH] =?UTF-8?q?git:=20Move=20=E2=80=98core.autocrlf=E2=80=99?=
>  =?UTF-8?q?=20settings.?=
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> Follow up of b5e567bb2b277f89af493ba8cd0799fdb368a184.
>
> * guix/git.scm (clone*): Move ‘core.autocrlf’ settings from here...
> (update-cached-checkout): ...to here.
>
> Change-Id: I0f91d348376f9953cfbc497148596b738705818b

I was wondering whether ‘update-cached-checkout’ is too late for this,
but I think it should work: it’s right before the actual checkout.

Feel free to push.

Thanks,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 14 May 2025 11:24:46 GMT) Full text and rfc822 format available.

This bug report was last modified 39 days ago.

Previous Next


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