Le 2017-11-07 15:11, myglc2 a écrit :
On 11/07/2017 at 14:13 julien lepiller writes:
This new version outputs something like this :
guix system: error: failed to load 'vm-image.tmpl':
vm-image.tmpl:6:0: vm-image.tmpl:6:0: Package module "abc" does not
exist.
Check the "use-package-modules" line in your configuration.
Thanks Julien, I tried the patch and it works for me. I think it is a
great improvement.
Small suggestion: is it feasible for the last line to read:
Please add a module containing "abc" to the "use-package-modules" line
in your configuration.
Wouldn't that be confusing though?
Maybe you're confused because modules have the same name as some
packages,
but there is no relation between a package name and its module in
general.
In (use-package-modules abc), abc refers to a file named
'gnu/packages/abc.go'
and the error happens when this file doesn't exist.
Maybe that last line could be a hint as to how to find the correct
module, though,
such as:
guix system: error: failed to load 'vm-image.tmpl':
vm-image.tmpl:6:0: vm-image.tmpl:6:0: Package module "abc" does not
exist.
Check the "use-package-modules" line in your configuration.
Hint: You may use `guix package -s foo` to search for foo's location.
Hint: If you get the line "location: gnu/packages/ssh.scm:174:2",
Hint: you want to add ssh in use-package-modules.
And similarly with services:
guix system: error: failed to load 'vm-image.tmpl':
vm-image.tmpl:7:0: vm-image.tmpl:7:0: Service module "abc" does not
exist.
Check the "use-service-modules" line in your configuration.
Hint: You may use `guix system search foo` to search for foo's location.
Hint: If you get the line "location: gnu/services/ssh.scm:188:2",
Hint: you want to add ssh in use-service-modules.
Maybe that's too much?
TIA - George
From 3efdec7eb56d8ac52b6af00b0c3046456054fe41 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <jul...@lepiller.eu>
Date: Tue, 7 Nov 2017 11:46:34 +0100
Subject: [PATCH] Catch use-modules errors in configuration.
* gnu.scm (use-package-modules, use-service-modules, use-system-modules):
Catch use-modules errors and show a small explanation about it.
---
gnu.scm | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/gnu.scm b/gnu.scm
index 913ce6160..64c752915 100644
--- a/gnu.scm
+++ b/gnu.scm
@@ -52,13 +52,47 @@
(module-use! i (resolve-interface m))))
%public-modules)))
+(define (import-error type module syntax)
+ (define package-hint
+ (string-append
+ "Hint: You may use `guix package -s foo` to search for foo's location.\n"
+ "Hint: If you get the line \"location: gnu/packages/ssh.scm:174:2\",\n"
+ "Hint: you want to add ssh in use-package-modules."))
+ (define service-hint
+ (string-append
+ "Hint: You may use `guix system search foo` to search for foo's location.\n"
+ "Hint: If you get the line \"location: gnu/services/ssh.scm:188:2\",\n"
+ "Hint: you want to add ssh in use-service-modules."))
+ (error (string-append
+ type " module \"" module "\" does not exist.\n"
+ "Check the \"" syntax "\" line in your configuration.\n"
+ (if (equal? type "Package")
+ package-hint
+ (if (equal? type "Service")
+ service-hint
+ "")))))
+
(define-syntax-rule (use-package-modules module ...)
- (use-modules (gnu packages module) ...))
+ (begin
+ (catch #t (lambda () (use-modules (gnu packages module)))
+ (lambda _
+ (import-error "Package" (symbol->string 'module) "use-package-modules")))
+ ...))
(define-syntax-rule (use-service-modules module ...)
- (use-modules (gnu services module) ...))
+ (begin
+ (catch #t (lambda () (use-modules (gnu services module)))
+ (lambda _
+ (import-error "Service" (symbol->string 'module) "use-service-modules")))
+ ...))
+
(define-syntax-rule (use-system-modules module ...)
- (use-modules (gnu system module) ...))
+ (begin
+ (catch #t (lambda () (use-modules (gnu system module)))
+ (lambda _
+ (import-error "System" (symbol->string 'module) "use-system-modules")))
+ ...))
+
;;; gnu.scm ends here
--
2.13.6