From 83020265455d858ffffbbae07c2a53ff17c2388a Mon Sep 17 00:00:00 2001 From: Bryan Gardiner Date: Fri, 17 Mar 2023 21:36:13 -0700 Subject: [PATCH] Fix crash when inspecting Nix package with no deps (related to issue #12). --- CHANGELOG.md | 4 ++++ src/nvd | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96a0f47..7f34651 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.2.2 (unreleased) +- Fixed crash when `nix-store --query --references` returns nothing (e.g. for a + Nix package with no dependencies), which causes the assertion from issue #12 + to fail. + ## 0.2.1 (2023-03-17) - Fixed reference to undefined variable in `StorePath` constructor (issue #12), diff --git a/src/nvd b/src/nvd index 30c8b7b..fefe67e 100755 --- a/src/nvd +++ b/src/nvd @@ -228,11 +228,14 @@ class PackageManifest: @staticmethod def parse_tree(root: Path) -> "PackageManifest": - direct_deps: List[str] = subprocess.run( + direct_deps_str: str = subprocess.run( [make_nix_bin_path("nix-store"), "--query", "--references", str(root)], stdout=PIPE, text=True - ).stdout.rstrip("\n").split("\n") + ).stdout.rstrip("\n") + + direct_deps: List[str] = \ + direct_deps_str.split("\n") if direct_deps_str else [] packages = [] for dep_path in direct_deps: