repl-overlays are not exempt from pure eval restrictions in debugger mode #777

Open
opened 2025-03-28 20:17:51 +00:00 by jade · 3 comments
Owner
$ nix eval --expr 'builtins.break true' --repl-overlays /dev/null --debugger
info: breakpoint reached

Lix 2.93.0-dev-pre20250313-a4514e4 debugger
Type :? for help.
Loading 'repl-overlays'...
error:
       … while calling the 'break' builtin
         at «string»:1:1:
            1| builtins.break true
             | ^

       error: access to absolute path '/dev/null' is forbidden in pure eval mode (use '--impure' to override)

nix (Lix, like Nix) 2.93.0-dev-pre20250313-a4514e4

``` $ nix eval --expr 'builtins.break true' --repl-overlays /dev/null --debugger info: breakpoint reached Lix 2.93.0-dev-pre20250313-a4514e4 debugger Type :? for help. Loading 'repl-overlays'... error: … while calling the 'break' builtin at «string»:1:1: 1| builtins.break true | ^ error: access to absolute path '/dev/null' is forbidden in pure eval mode (use '--impure' to override) ``` `nix (Lix, like Nix) 2.93.0-dev-pre20250313-a4514e4`
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/3398 ("repl: fix repl-overlays in pure eval mode")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/3398", "number": 3398, "kind": "commit message"}], "cl_meta": {"3398": {"change_title": "repl: fix repl-overlays in pure eval mode"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/3398](https://gerrit.lix.systems/c/lix/+/3398) ("repl: fix repl-overlays in pure eval mode")
Member

I think this has regressed? I just hit this on main (currently faaa14a303) :/

$ nix eval --expr 'builtins.break true' --repl-overlays /dev/null --debugger
info: breakpoint reached

Lix 2.96.0-devpre20260408-dev_dirty debugger
Type :? for help.
Loading 'repl-overlays'...
error:
       … while calling the 'break' builtin
         at «string»:1:1:
            1| builtins.break true
             | ^

       error: access to absolute path '/dev/null' is forbidden in pure eval mode (use '--impure' to override)
I think this has regressed? I just hit this on main (currently faaa14a303dabc6309a52cc8e5eba86f9e29ccaf) :/ ```sh $ nix eval --expr 'builtins.break true' --repl-overlays /dev/null --debugger info: breakpoint reached Lix 2.96.0-devpre20260408-dev_dirty debugger Type :? for help. Loading 'repl-overlays'... error: … while calling the 'break' builtin at «string»:1:1: 1| builtins.break true | ^ error: access to absolute path '/dev/null' is forbidden in pure eval mode (use '--impure' to override) ```
jade reopened this issue 2026-04-28 15:04:57 +00:00
Member

So the problem with the original fix in 276add2cd7 is that the list of allowed paths for files (which is what's used by the evalFile call used for loading overlays) is initialized when the evaluator is first constructed, so just changing the pure-eval setting afterwards doesn't actually affect it (except just changing the error message).

Right now, the class that holds allowed search paths (EvalPaths, evaluator.paths inside the repl) has an allowPath method that can dynamically add a new path to search, but it doesn't have a disallowPath or removeAllowedPath method, so we'd need to add that to use it (or we'd risk breaking purity by allowing the overlay's path for the whole rest of the eval). Does that sound fine?

(and all this still doesn't fix the fact that repl overlays can't do impure eval stuff (such as using other paths inside of them) without forcing the expression immediately, but i think that's just a fundamental/design flaw more than a bug...)

So the problem with the original fix in [`276add2cd7`](https://git.lix.systems/lix-project/lix/commit/276add2cd7167d5c847e6440f7733c85166b9d53) is that the list of allowed paths for files (which is what's used by the `evalFile` call used for loading overlays) is initialized when the evaluator is first constructed, so just changing the `pure-eval` setting _afterwards_ doesn't actually affect it (except just changing the error message). Right now, the class that holds allowed search paths (`EvalPaths`, `evaluator.paths` inside the repl) has an `allowPath` method that can dynamically add a new path to search, but it doesn't have a `disallowPath` or `removeAllowedPath` method, so we'd need to add that to use it (or we'd risk breaking purity by allowing the overlay's path for the whole rest of the eval). Does that sound fine? (and all this still doesn't fix the fact that repl overlays can't do impure eval stuff (such as using other paths inside of them) without forcing the expression immediately, but i think that's just a fundamental/design flaw more than a bug...)
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#777
No description provided.