bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#54893: [PATCH] guix: git-download: Set locale to deal with Unicode i


From: Attila Lendvai
Subject: bug#54893: [PATCH] guix: git-download: Set locale to deal with Unicode in git metadata.
Date: Tue, 19 Apr 2022 20:09:55 +0200

Without this the git-fetch GEXP is run in an environment that uses ASCII
character encoding when strings are crossing the Guile - C boundary.  It means
that e.g. tag names that have Unicode chars in them will cause problems,
e.g. when walking and deleting the .git directory.

An example in the wild: https://github.com/klauspost/pgzip/tags

For more details see: https://issues.guix.gnu.org/54893

* guix/git-download.scm (git-fetch): Call setlocale to set it to en_US.utf8.
---

thanks Maxime, this indeed seems to work! and i have successfully
guix pull'ed it, too.

 guix/git-download.scm | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/guix/git-download.scm b/guix/git-download.scm
index 5e624b9ae9..2fc5a06490 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -104,6 +104,9 @@ (define guile-zlib
   (define gnutls
     (module-ref (resolve-interface '(gnu packages tls)) 'gnutls))
 
+  (define glibc-locales
+    (module-ref (resolve-interface '(gnu packages base)) 'glibc-locales))
+
   (define modules
     (delete '(guix config)
             (source-module-closure '((guix build git)
@@ -121,6 +124,13 @@ (define build
                          (guix build download-nar)
                          (guix swh)
                          (ice-9 match))
+            ;; We must set the locale to something/anything that will make the
+            ;; Guile FFI use a character encoding that is idempotent through a
+            ;; bytes->string string->bytes roundtrip.  Otherwise e.g. git tags
+            ;; with Unicode characters would break things.  For more details
+            ;; and an example see https://issues.guix.gnu.org/54893
+            (setenv "GUIX_LOCPATH" #+(file-append glibc-locales "/lib/locale"))
+            (setlocale LC_ALL "en_US.utf8")
 
             (define recursive?
               (call-with-input-string (getenv "git recursive?") read))
-- 
2.35.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]