diff --git a/src/nix/search.cc b/src/nix/search.cc index fca49350a..bbac56fcb 100644 --- a/src/nix/search.cc +++ b/src/nix/search.cc @@ -180,7 +180,7 @@ struct CmdSearch : InstallableCommand, MixJSON for (auto & [cursor, prefix] : installable->getCursor(*state, true)) visit(*cursor, parseAttrPath(*state, prefix)); - if (!results) + if (!json && !results) throw Error("no results for the given search term(s)!"); } };