New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a flag to start the REPL on evaluation errors #3901
Conversation
This allows interactively inspecting the state of the evaluator at the point of failure. Example: $ nix eval path:///home/eelco/Dev/nix/flake2#modules.hello-closure._final --start-repl-on-eval-errors error: --- TypeError -------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix at: (20:53) in file: /nix/store/4264z41dxfdiqr95svmpnxxxwhfplhy0-source/flake.nix 19| 20| _final = builtins.foldl' (xs: mod: xs // (mod._module.config { config = _final; })) _defaults _allModules; | ^ 21| }; attempt to call something which is not a function but a set Starting REPL to allow you to inspect the current state of the evaluator. The following extra variables are in scope: arg, fun Welcome to Nix version 2.4. Type :? for help. nix-repl> fun error: --- EvalError -------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix at: (150:28) in file: /nix/store/4264z41dxfdiqr95svmpnxxxwhfplhy0-source/flake.nix 149| 150| tarballClosure = (module { | ^ 151| extends = [ self.modules.derivation ]; attribute 'derivation' missing nix-repl> :t fun a set nix-repl> builtins.attrNames fun [ "tarballClosure" ] nix-repl>
--debugger? |
This would be the easiest fix for #963 |
It would be useful to show for such errors at the end Something like |
Co-authored-by: Domen Kožar <domen@dev.si>
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-to-extract-signal-from-almost-useless-error-message/11733/13 |
What's the status on this PR? I'd really like to be able to use this feature. |
cc @bburdette |
@lf- I have been hacking on this problem a bit. i have a branch that builds and kicks you into the repl on most eval exceptions, and doesn't appear to significantly impact stack size. I'm still grappling with how best to get an appropriate set of symbols in the repl though. Usually its easy enough to access an Env at exception time, but Envs contain only values, not symbols, and those values are stored in segfault-terminated arrays. Envs are mainly for looking up symbol values where the location of the value within the env is known already, not introspecting to discover what symbols are available. My current thinking is maybe adding a value count to the Env would be inexpensive and allow iterating over the values to find Attr sets to add to the repl namespace. |
I marked this as stale due to inactivity. → More info |
This is really cool and could be extremely useful. |
This allows interactively inspecting the state of the evaluator at the point of failure.
Example:
TODO: