diff options
author | Christopher Baines <mail@cbaines.net> | 2021-10-12 20:12:13 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-10-12 20:12:13 +0100 |
commit | a4d0ec6bc564bbe98d3e6c03be41de16edbda928 (patch) | |
tree | 01f3871208c8a10f382986d26f609ddf36199418 | |
parent | fda913d7a912bd810ef860c12b65166b863acb7a (diff) | |
download | build-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.
-rw-r--r-- | guix-build-coordinator/utils.scm | 32 | ||||
-rw-r--r-- | scripts/guix-build-coordinator-agent.in | 2 | ||||
-rw-r--r-- | scripts/guix-build-coordinator.in | 2 |
3 files changed, 35 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)) diff --git a/scripts/guix-build-coordinator-agent.in b/scripts/guix-build-coordinator-agent.in index c863e9e..0ac36f9 100644 --- a/scripts/guix-build-coordinator-agent.in +++ b/scripts/guix-build-coordinator-agent.in @@ -140,6 +140,8 @@ (max 256 columns) 256)))) +(simple-format (current-error-port) "locale is ~A\n" (check-locale!)) + (let ((opts (parse-options %options %option-defaults (cdr (program-arguments))))) diff --git a/scripts/guix-build-coordinator.in b/scripts/guix-build-coordinator.in index 9760968..b112262 100644 --- a/scripts/guix-build-coordinator.in +++ b/scripts/guix-build-coordinator.in @@ -52,6 +52,8 @@ (guix-build-coordinator build-allocator) (guix-build-coordinator client-communication)) +(simple-format (current-error-port) "locale is ~A\n" (check-locale!)) + (define %base-options ;; Specifications of the command-line options (list (option '("secret-key-base-file") #t #f |