From 49fa3e186981ef8dece5486d5d6ddf9b38a9d10a Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Sun, 23 Mar 2025 22:13:14 +0000 Subject: [PATCH] libcmd/repl: Fix missing `runNix` in repl Without this :u, :sh and :i repl commands fail with: > Cannot run 'nix-shell'/`nix-env` because no method of calling the Nix > CLI was provided. This is a configuration problem pertaining to how > this program was built. Remove the default ctor argument as it evidently makes catching refactoring bugs much harder. `NixRepl` implementation lives completely in `repl.cc`, so we can be as explicit as necessary. (cherry picked from commit 44055dc09d12e85c3187a1a793c129ccb5d89050) --- src/libcmd/repl.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 68bf41329..38b219643 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -124,7 +124,7 @@ std::string removeWhitespace(std::string s) NixRepl::NixRepl(const LookupPath & lookupPath, nix::ref store, ref state, - std::function getValues, RunNix * runNix = nullptr) + std::function getValues, RunNix * runNix) : AbstractNixRepl(state) , debugTraceIndex(0) , getValues(getValues) @@ -841,7 +841,8 @@ std::unique_ptr AbstractNixRepl::create( lookupPath, std::move(store), state, - getValues + getValues, + runNix ); } @@ -859,7 +860,8 @@ ReplExitStatus AbstractNixRepl::runSimple( lookupPath, openStore(), evalState, - getValues + getValues, + /*runNix=*/nullptr ); repl->initEnv();