summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--guix/scripts/package.scm10
-rw-r--r--tests/guix-package.sh4
2 files changed, 11 insertions, 3 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 500fc9ac90..5743816324 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -771,9 +771,13 @@ processed, #f otherwise."
       (('show requested-name)
        (let-values (((name version)
                      (package-name->name+version requested-name)))
-         (leave-on-EPIPE
-          (for-each (cute package->recutils <> (current-output-port))
-                    (find-packages-by-name name version)))
+         (match (find-packages-by-name name version)
+           (()
+            (leave (G_ "~a~@[@~a~]: package not found~%") name version))
+           (packages
+            (leave-on-EPIPE
+             (for-each (cute package->recutils <> (current-output-port))
+                       packages))))
          #t))
 
       (('search-paths kind)
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index f7dfbfad00..7eeb4304d1 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -106,6 +106,10 @@ guix package --show=guile | grep "^name: guile"
 # Ensure `--show' doesn't fail for packages with non-package inputs.
 guix package --show=texlive
 
+# Fail for non-existent packages or package/version pairs.
+if guix package --show=does-not-exist; then false; else true; fi
+if guix package --show=emacs@42; then false; else true; fi
+
 # Search.
 LC_MESSAGES=C
 export LC_MESSAGES