From d05e0b9f1fedfe1700959cc6045ce9bc25b9e955 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Wed, 22 May 2024 16:58:35 -0700 Subject: [PATCH] fix: enlarge envSize by several times to not be close to nixpkgs size nixpkgs has 23000 attributes, and our previous limit would be hit if you have more than one nixpkgs in the environment, for example, because `repl-overlays` will load the new stuff from the environment on top of the existing environment. This is not really testable since if we did write such a test, it would just be testing this constant tbh... Fixes: https://git.lix.systems/lix-project/lix/issues/337 Change-Id: I49197bfb4db55b082f914f0d70e84f5f5f110954 --- src/libcmd/repl.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 525c25560..89691d33a 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -90,7 +90,8 @@ struct NixRepl Strings loadedFiles; std::function getValues; - const static int envSize = 32768; + // Uses 8MiB of memory. It's fine. + const static int envSize = 1 << 20; std::shared_ptr staticEnv; Env * env; int displ; @@ -854,6 +855,11 @@ void NixRepl::loadReplOverlays() replInitFilesFunction->determinePos(noPos) ); + // n.b. this does in fact load the stuff into the environment twice (once + // from the superset of the environment returned by repl-overlays and once + // from the thing itself), but it's not fixable because clearEnv here could + // lead to dangling references to the old environment in thunks. + // https://git.lix.systems/lix-project/lix/issues/337#issuecomment-3745 addAttrsToScope(newAttrs); }