Archived
1
0
Fork 0

discovery: Hide Guile warnings when loading modules.

Fixes <https://issues.guix.gnu.org/43747>.

* guix/discovery.scm (scheme-modules): Parameterize 'current-warning-port'.
This commit is contained in:
Ludovic Courtès 2021-09-30 10:16:02 +02:00
parent 270b30705d
commit bedcba8f5c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -107,19 +107,25 @@ name and the exception key and arguments."
(define prefix-len (define prefix-len
(string-length directory)) (string-length directory))
(filter-map (lambda (file) ;; Hide Guile warnings such as "source file [...] newer than compiled" when
(let* ((relative (string-drop file prefix-len)) ;; loading user code, unless we're hacking on Guix proper. See
(module (file-name->module-name relative))) ;; <https://issues.guix.gnu.org/43747>.
(catch #t (parameterize ((current-warning-port (if (getenv "GUIX_UNINSTALLED")
(lambda () (current-warning-port)
(resolve-interface module)) (%make-void-port "w"))))
(lambda args (filter-map (lambda (file)
;; Report the error, but keep going. (let* ((relative (string-drop file prefix-len))
(warn file module args) (module (file-name->module-name relative)))
#f)))) (catch #t
(scheme-files (if sub-directory (lambda ()
(string-append directory "/" sub-directory) (resolve-interface module))
directory)))) (lambda args
;; Report the error, but keep going.
(warn file module args)
#f))))
(scheme-files (if sub-directory
(string-append directory "/" sub-directory)
directory)))))
(define* (scheme-modules* directory #:optional sub-directory) (define* (scheme-modules* directory #:optional sub-directory)
"Return the list of module names found under SUB-DIRECTORY in DIRECTORY. "Return the list of module names found under SUB-DIRECTORY in DIRECTORY.