[Nix#9531] nix repl tab completion does not print errors. Uncanny. #91

Open
opened 2024-03-16 06:44:51 +00:00 by lix-bot · 0 comments
Member

Upstream-Issue: NixOS/nix#9531

Describe the bug

Tab completion is essential for being productive in the repl.

When an expression does not evaluate, tab completion just "ends" without any indication that something went wrong, as if it's an empty attribute set or a primitive value.

This always confuses me for a short amount of time, until I realise that I need to hit enter to see the error.

Please don't stall my brain.

Steps To Reproduce

$ nix repl ~/nixpkgs
nix-repl>  n = nixos {}

nix-repl> n.to<TAB>
n.toplevel
nix-repl> n.toplevel<TAB>
n.toplevel
nix-repl> n.toplevel<TAB>
n.toplevel
nix-repl> n.toplevel<ENTER>
error:
       Failed assertions:
       - The ‘fileSystems’ option does not specify your root file system.
       - You must set the option ‘boot.loader.grub.devices’ or 'boot.loader.grub.mirroredBoots' to make the system bootable.

Expected behavior

In my experience with bash completing Nix attribute paths, it's tricky to get them right, so that they balance laziness and minimal completion steps.
It seems that the missing piece here is just to allow printing the error, or actively print the error.
While it's possible to go overboard and have more intricate rules that complete more faster, that runs the risk of producing the error too soon, before the user realises which attribute they entered. Hence the 2 s below.

$ nix repl ~/nixpkgs
nix-repl>  n = nixos {}

nix-repl> n.to<TAB>
n.toplevel
nix-repl> n.toplevel<TAB>
error:
       Failed assertions:
       - The ‘fileSystems’ option does not specify your root file system.
       - You must set the option ‘boot.loader.grub.devices’ or 'boot.loader.grub.mirroredBoots' to make the system bootable.

nix-env --version output

Additional context

Priorities

Add 👍 to issues you find important.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/9531 **Describe the bug** Tab completion is essential for being productive in the repl. When an expression does not evaluate, tab completion just "ends" without any indication that something went wrong, as if it's an empty attribute set or a primitive value. This always confuses me for a short amount of time, until I realise that I need to hit enter to see the error. Please don't stall my brain. **Steps To Reproduce** ```console $ nix repl ~/nixpkgs nix-repl> n = nixos {} nix-repl> n.to<TAB> n.toplevel nix-repl> n.toplevel<TAB> n.toplevel nix-repl> n.toplevel<TAB> n.toplevel nix-repl> n.toplevel<ENTER> error: Failed assertions: - The ‘fileSystems’ option does not specify your root file system. - You must set the option ‘boot.loader.grub.devices’ or 'boot.loader.grub.mirroredBoots' to make the system bootable. ``` **Expected behavior** In my experience with bash completing Nix attribute paths, it's tricky to get them right, so that they balance laziness and minimal completion steps. It seems that the missing piece here is just to allow printing the error, or actively print the error. While it's possible to go overboard and have more intricate rules that complete more faster, that runs the risk of producing the error too soon, before the user realises which attribute they entered. Hence the 2 <TAB>s below. ```console $ nix repl ~/nixpkgs nix-repl> n = nixos {} nix-repl> n.to<TAB> n.toplevel nix-repl> n.toplevel<TAB> error: Failed assertions: - The ‘fileSystems’ option does not specify your root file system. - You must set the option ‘boot.loader.grub.devices’ or 'boot.loader.grub.mirroredBoots' to make the system bootable. ``` **`nix-env --version` output** **Additional context** **Priorities** Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
lix-bot added the
bug
imported
labels 2024-03-16 06:44:51 +00:00
jade added the
Area/repl
label 2024-05-30 07:13:14 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#91
No description provided.