GNU bug report logs -
#75007
[PATCH] guile-launcher: Avoid the “C” locale and try “C.UTF-8”.
Previous Next
Reported by: Ludovic Courtès <ludo <at> gnu.org>
Date: Sat, 21 Dec 2024 10:45:02 UTC
Severity: normal
Tags: patch
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 75007 in the body.
You can then email your comments to 75007 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org
:
bug#75007
; Package
guix-patches
.
(Sat, 21 Dec 2024 10:45:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
New bug report received and forwarded. Copy sent to
guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org
.
(Sat, 21 Dec 2024 10:45:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
This is a followup to ed0cd12a82b429bc5058f693a0f75f2ba0ee47c4, which
adds the C.UTF-8 locale to the glibc package, and
ee4e79f871bc2f848ce4b4a176bb725ab71e3cd6, which changed the default to
“C.UTF-8” for ‘guix’ commands.
Fixes a bug whereby starting ‘guix’ in an environment where the LC_*
variables are unset would start it in the “C” locale:
echo '(pk (setlocale LC_ALL))' | guix shell -CW coreutils -- guix repl
This would lead to breakage for commands such as ‘guix substitute’ that
need to run in a UTF-8 locale.
* gnu/packages/aux-files/guile-launcher.c (main): Try “C.UTF-8” before
“en_US.UTF-8”. Do that also when the current locale is “C”.
* guix/ui.scm (install-locale): Likewise.
Change-Id: I36da4db8f898f1083b33760e1ab46c3a257de811
---
gnu/packages/aux-files/guile-launcher.c | 16 +++++++++++-----
guix/ui.scm | 4 +++-
2 files changed, 14 insertions(+), 6 deletions(-)
Hi!
Until now, ‘guix’ wouldn’t mind running in the C locale, but that’s not
good for ‘guix substitute’ and other commands started by ‘guix-daemon’.
This is something colleagues and I noticed while running ‘guix-daemon’
in a GitLab-CI container where LC_* were unset.
Thoughts?
Ludo’.
diff --git a/gnu/packages/aux-files/guile-launcher.c b/gnu/packages/aux-files/guile-launcher.c
index c205477f64..44f7e1f432 100644
--- a/gnu/packages/aux-files/guile-launcher.c
+++ b/gnu/packages/aux-files/guile-launcher.c
@@ -84,11 +84,17 @@ int
main (int argc, char **argv)
{
/* Try to install the current locale; remain silent if it fails. */
- if (setlocale (LC_ALL, "") == NULL)
- /* The 'guix pull'-provided 'guix' includes at least en_US.utf8 so use
- that. That gives us UTF-8 support for 'scm_to_locale_string', etc.,
- which is always preferable over the C locale. */
- setlocale (LC_ALL, "en_US.utf8");
+ char *locale = setlocale (LC_ALL, "");
+ if (locale == NULL || strcmp (locale, "C") == 0)
+ {
+ /* The 'guix pull'-provided 'guix' includes at least C.UTF-8 (which is
+ baked into glibc, except when cross-compiling) so use that, and fall
+ back to en_US.UTF-8. That gives us UTF-8 support for
+ 'scm_to_locale_string', etc., which is always preferable over the C
+ locale. */
+ if (setlocale (LC_ALL, "C.UTF-8") == NULL)
+ setlocale (LC_ALL, "en_US.utf8");
+ }
const char *str;
str = getenv ("GUILE_LOAD_PATH");
diff --git a/guix/ui.scm b/guix/ui.scm
index eba12c8616..14d6874795 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -521,7 +521,9 @@ (define (install-locale)
"Install the current locale settings."
(catch 'system-error
(lambda _
- (setlocale LC_ALL ""))
+ (when (string=? (setlocale LC_ALL "") "C")
+ ;; If the current locale is "C", prefer "C.UTF-8".
+ (setlocale LC_ALL "C.UTF-8")))
(lambda args
(display-hint (G_ "Consider installing the @code{glibc-locales} package
and defining @code{GUIX_LOCPATH}, along these lines:
base-commit: 777fde8299d5b0050cae661d403374a7dd87f6ab
--
2.46.0
Reply sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
You have taken responsibility.
(Sat, 04 Jan 2025 22:40:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
bug acknowledged by developer.
(Sat, 04 Jan 2025 22:40:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 75007-done <at> debbugs.gnu.org (full text, mbox):
Ludovic Courtès <ludo <at> gnu.org> skribis:
> This is a followup to ed0cd12a82b429bc5058f693a0f75f2ba0ee47c4, which
> adds the C.UTF-8 locale to the glibc package, and
> ee4e79f871bc2f848ce4b4a176bb725ab71e3cd6, which changed the default to
> “C.UTF-8” for ‘guix’ commands.
>
> Fixes a bug whereby starting ‘guix’ in an environment where the LC_*
> variables are unset would start it in the “C” locale:
>
> echo '(pk (setlocale LC_ALL))' | guix shell -CW coreutils -- guix repl
>
> This would lead to breakage for commands such as ‘guix substitute’ that
> need to run in a UTF-8 locale.
>
> * gnu/packages/aux-files/guile-launcher.c (main): Try “C.UTF-8” before
> “en_US.UTF-8”. Do that also when the current locale is “C”.
> * guix/ui.scm (install-locale): Likewise.
>
> Change-Id: I36da4db8f898f1083b33760e1ab46c3a257de811
Pushed as d7c8a5ff3c76461d469364e920ec4f09f9e3c126.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 02 Feb 2025 12:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.