From 8972f7c14a196041f8faef2f2c3f7bd705ab4e07 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Wed, 6 May 2015 15:16:35 +0000 Subject: [PATCH] nix-collect-garbage: Do not pass an empty argument. Closes #530 --- src/nix-collect-garbage/nix-collect-garbage.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nix-collect-garbage/nix-collect-garbage.cc b/src/nix-collect-garbage/nix-collect-garbage.cc index 366a378a1..ae75fd621 100644 --- a/src/nix-collect-garbage/nix-collect-garbage.cc +++ b/src/nix-collect-garbage/nix-collect-garbage.cc @@ -45,7 +45,11 @@ void removeOldGenerations(std::string dir) if (link.find("link") != string::npos) { printMsg(lvlInfo, format("removing old generations of profile %1%") % path); - runProgramSimple(settings.nixBinDir + "/nix-env", Strings{"-p", path, "--delete-generations", gen, dryRun ? "--dry-run" : ""}); + auto args = Strings{"-p", path, "--delete-generations", gen}; + if (dryRun) { + args.push_back("--dry-run"); + } + runProgramSimple(settings.nixBinDir + "/nix-env", args); } } else if (type == DT_DIR) { removeOldGenerations(path);