aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/utils.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2021-10-12 20:12:13 +0100
committerChristopher Baines <mail@cbaines.net>2021-10-12 20:12:13 +0100
commita4d0ec6bc564bbe98d3e6c03be41de16edbda928 (patch)
tree01f3871208c8a10f382986d26f609ddf36199418 /guix-build-coordinator/utils.scm
parentfda913d7a912bd810ef860c12b65166b863acb7a (diff)
downloadbuild-coordinator-a4d0ec6bc564bbe98d3e6c03be41de16edbda928.tar
build-coordinator-a4d0ec6bc564bbe98d3e6c03be41de16edbda928.tar.gz
Try to guard against broken locale settings
As falling back to the C locale can break things, like creating nars from outputs.
Diffstat (limited to 'guix-build-coordinator/utils.scm')
-rw-r--r--guix-build-coordinator/utils.scm32
1 files changed, 31 insertions, 1 deletions
diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm
index c619a12..5d365a6 100644
--- a/guix-build-coordinator/utils.scm
+++ b/guix-build-coordinator/utils.scm
@@ -65,7 +65,9 @@
running-on-the-hurd?
- get-gc-metrics-updater))
+ get-gc-metrics-updater
+
+ check-locale!))
(eval-when (eval load compile)
(begin
@@ -931,3 +933,31 @@ again."
(let ((value (assq-ref stats name)))
(metric-set metric value))))
metrics))))
+
+(define (check-locale!)
+ (with-exception-handler
+ (lambda (exn)
+ (display
+ (simple-format
+ #f
+ "exception when calling setlocale: ~A
+falling back to en_US.utf8\n"
+ exn)
+ (current-error-port))
+
+ (with-exception-handler
+ (lambda (exn)
+ (display
+ (simple-format
+ #f
+ "exception when calling setlocale with en_US.utf8: ~A\n"
+ exn)
+ (current-error-port))
+
+ (exit 1))
+ (lambda _
+ (setlocale LC_ALL "en_US.utf8"))
+ #:unwind? #t))
+ (lambda _
+ (setlocale LC_ALL ""))
+ #:unwind? #t))