Subject: bug#52831: [installer] Locale problems with nss-certs

From: Mathieu Othacehe <[email-masked]>
Date: Wed, 29 Dec 2021 18:26:05 +0100

Hello Leo,

> While testing the Guix System installer, I noticed that installation of
> nss-certs has some problems that seem related to locales.

What locale did you pick in the installer?

I think the issue lies in the (gnu installer utils) module, run-command
procedure:

--8<---------------cut here---------------start------------->8---
  (when locale
    (let ((supported? (false-if-exception
                       (setlocale LC_ALL locale))))
      ;; If LOCALE is not supported, then set LANGUAGE, which might at
      ;; least give us translated messages.
      (if supported?
          (setenv "LC_ALL" locale)
          (setenv "LANGUAGE"
                  (string-take locale
                               (or (string-index locale #\_)
                                   (string-length locale)))))))
--8<---------------cut here---------------end--------------->8---

If you pick a locale such as en_AG.utf8 which is not supported by the
glibc-utf8-locales package, then supported? is #f, which means that
LC_ALL is never set.

The following patch fixes it for me.

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm
index bb97bc5560..d745996a3a 100644
--- a/gnu/installer/utils.scm
+++ b/gnu/installer/utils.scm
@@ -97,10 +97,12 @@ (define (pause)
       ;; least give us translated messages.
       (if supported?
           (setenv "LC_ALL" locale)
-          (setenv "LANGUAGE"
-                  (string-take locale
-                               (or (string-index locale #\_)
-                                   (string-length locale)))))))
+          (begin
+            (setlocale LC_ALL "en_US.utf8")
+            (setenv "LANGUAGE"
+                    (string-take locale
+                                 (or (string-index locale #\_)
+                                     (string-length locale))))))))
 
   (guard (c ((invoke-error? c)
              (newline)
--8<---------------cut here---------------end--------------->8---

WDYT?

Thanks,

Mathieu