summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/packages.scm4
-rw-r--r--tests/packages.scm9
2 files changed, 12 insertions, 1 deletions
diff --git a/gnu/packages.scm b/gnu/packages.scm
index 5a76e9b9ef..bbd460a083 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -300,13 +300,15 @@ use NAME@VERSION instead~%")))
(_
(if version
(leave (_ "~A: package not found for version ~a~%") name version)
- (or fallback?
+ (if (not fallback?)
;; XXX: Fallback to the older specification style with an hyphen
;; between NAME and VERSION, for backward compatibility.
(call-with-values
(lambda ()
(hyphen-separated-name->name+version name))
(cut %find-package spec <> <> #:fallback? #t))
+
+ ;; The fallback case didn't find anything either, so bail out.
(leave (_ "~A: unknown package~%") name))))))
(define (specification->package spec)
diff --git a/tests/packages.scm b/tests/packages.scm
index 9a2dbee35a..823ede1f25 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -788,6 +788,15 @@
(guix-package "-p" (derivation->output-path prof)
"--search-paths"))))))
+(test-equal "specification->package when not found"
+ 'quit
+ (catch 'quit
+ (lambda ()
+ ;; This should call 'leave', producing an error message.
+ (specification->package "this-package-does-not-exist"))
+ (lambda (key . args)
+ key)))
+
(test-end "packages")