From 3b80b81358b3861ca3794105c8eb4395df97846b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 10 Dec 2017 23:41:21 +0100 Subject: ui: Display hints to resolve profile collisions. Fixes . Reported by Ben Sturmfels . * guix/ui.scm (display-collision-resolution-hint): New procedure. (call-with-error-handling): Call it upon '&profile-collistion-error'. --- guix/ui.scm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'guix/ui.scm') diff --git a/guix/ui.scm b/guix/ui.scm index e40fe576ba..fa747b7b08 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -502,6 +502,26 @@ interpreted." (x (leave (G_ "unknown unit: ~a~%") unit))))))) +(define (display-collision-resolution-hint collision) + "Display hints on how to resolve COLLISION, a &profile-collistion-error." + (define (top-most-entry entry) + (let loop ((entry entry)) + (match (force (manifest-entry-parent entry)) + (#f entry) + (parent (loop parent))))) + + (let* ((first (profile-collision-error-entry collision)) + (second (profile-collision-error-conflict collision)) + (name1 (manifest-entry-name (top-most-entry first))) + (name2 (manifest-entry-name (top-most-entry second)))) + (if (string=? name1 name2) + (display-hint (format #f (G_ "You cannot have two different versions +or variants of @code{~a} in the same profile.") + name1)) + (display-hint (format #f (G_ "Try upgrading both @code{~a} and @code{~a}, +or remove one of them from the profile.") + name1 name2))))) + (define (call-with-error-handling thunk) "Call THUNK within a user-friendly error handler." (define (port-filename* port) @@ -570,6 +590,7 @@ interpreted." (manifest-entry-output* conflict) (manifest-entry-item conflict)) (report-parent-entries conflict) + (display-collision-resolution-hint c) (exit 1))) ((nar-error? c) (let ((file (nar-error-file c)) -- cgit v1.2.3 From 399993f8040a18d0e38217d2949822954f45dc0e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 18 Dec 2017 14:55:26 +0100 Subject: ui: Non-zero exit for compound '&message' and '&error-location' conditions. * guix/ui.scm (call-with-error-handling): When both 'message?' and 'error-location?' are true, add call to 'exit'. --- guix/ui.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guix/ui.scm') diff --git a/guix/ui.scm b/guix/ui.scm index fa747b7b08..2b7cc3d41a 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -621,7 +621,8 @@ directories:~{ ~a~}~%") (format (current-error-port) (G_ "~a: error: ~a~%") (location->string (error-location c)) - (gettext (condition-message c) %gettext-domain))) + (gettext (condition-message c) %gettext-domain)) + (exit 1)) ((message-condition? c) ;; Normally '&message' error conditions have an i18n'd message. (leave (G_ "~a~%") -- cgit v1.2.3