diff --git a/src/libexpr/flake/lockfile.cc b/src/libexpr/flake/lockfile.cc index 68443211b..f3ea9063f 100644 --- a/src/libexpr/flake/lockfile.cc +++ b/src/libexpr/flake/lockfile.cc @@ -2,8 +2,10 @@ #include "store-api.hh" #include "url-parts.hh" +#include #include +#include #include namespace nix::flake { @@ -46,18 +48,18 @@ StorePath LockedNode::computeStorePath(Store & store) const } -static std::shared_ptr doFind(const ref& root, const InputPath & path, std::vector& visited) { +static std::shared_ptr doFind(const ref& root, const InputPath & path, std::vector& visited) { auto pos = root; - auto pathS = printInputPath(path); - auto found = std::find(visited.cbegin(), visited.cend(), pathS); + auto found = std::find(visited.cbegin(), visited.cend(), path); if(found != visited.end()) { - std::vector cycle(found, visited.cend()); - cycle.push_back(pathS); + std::vector cycle; + std::transform(found, visited.cend(), std::back_inserter(cycle), printInputPath); + cycle.push_back(printInputPath(path)); throw Error("follow cycle detected: [%s]", concatStringsSep(" -> ", cycle)); } - visited.push_back(pathS); + visited.push_back(path); for (auto & elem : path) { if (auto i = get(pos->inputs, elem)) { @@ -78,7 +80,7 @@ static std::shared_ptr doFind(const ref& root, const InputPath & pat std::shared_ptr LockFile::findInput(const InputPath & path) { - std::vector visited; + std::vector visited; return doFind(root, path, visited); }