diff --git a/src/nix/cat.cc b/src/nix/cat.cc index 5b93d560b..1284b50fd 100644 --- a/src/nix/cat.cc +++ b/src/nix/cat.cc @@ -76,6 +76,8 @@ struct CmdCatNar : StoreCommand, MixCat void run(ref store) override { AutoCloseFD fd = open(narPath.c_str(), O_RDONLY); + if (!fd) + throw SysError("opening NAR file '%s'", narPath); auto source = FdSource{fd.get()}; auto narAccessor = makeNarAccessor(source); auto listing = listNar(narAccessor, CanonPath::root, true); diff --git a/src/nix/ls.cc b/src/nix/ls.cc index 846af246d..82721222e 100644 --- a/src/nix/ls.cc +++ b/src/nix/ls.cc @@ -146,6 +146,8 @@ struct CmdLsNar : Command, MixLs void run() override { AutoCloseFD fd = open(narPath.c_str(), O_RDONLY); + if (!fd) + throw SysError("opening NAR file '%s'", narPath); auto source = FdSource{fd.get()}; auto narAccessor = makeNarAccessor(source); auto listing = listNar(narAccessor, CanonPath::root, true);