nix-repl: using tab-completion on a import of a non-existent file crashes the repl. #340

Closed
opened 2024-05-23 00:06:50 +00:00 by janik · 4 comments
Member

Describe the bug

When using tab-completion on a import of a non-existent file nix-repl crashes.

Steps To Reproduce

Crate a file like:

# text.nix
{
  someImport = import ./this_file_does_not_exist;
}

Open a repl and type:

nix-repl> test = import ./test.nix

nix-repl> test.someImport.<tab>

When pressing tab for completion the repl crashes (and sometimes also the shell).

Expected behavior

Handling of that edge case in a more graceful manner so that it doesn't crash the repl and maybe prints a warning to the user instead or just does nothing.

nix --version output

nix (Lix, like Nix) 2.90.0-lix

## Describe the bug When using tab-completion on a import of a non-existent file nix-repl crashes. ## Steps To Reproduce Crate a file like: ```nix # text.nix { someImport = import ./this_file_does_not_exist; } ``` Open a repl and type: ```nix nix-repl> test = import ./test.nix nix-repl> test.someImport.<tab> ``` When pressing tab for completion the repl crashes (and sometimes also the shell). ## Expected behavior Handling of that edge case in a more graceful manner so that it doesn't crash the repl and maybe prints a warning to the user instead or just does nothing. ## `nix --version` output nix (Lix, like Nix) 2.90.0-lix
janik added the
bug
label 2024-05-23 00:06:50 +00:00
Member

For clarity since when you said "crashes" I expected e.g. a segfault or something:

$ nix repl
Lix 2.90.0-lixpre20240506-106b959
Type :? for help.
nix-repl> test = import ./test.nix

nix-repl> test.someImport.<tab>error:
       … while evaluating the attribute 'someImport'
         at /tmp/test.nix:2:3:
            1| {
            2|   someImport = import ./this_file_does_not_exist;
             |   ^
            3| }

       … while calling the 'import' builtin
         at /tmp/test.nix:2:16:
            1| {
            2|   someImport = import ./this_file_does_not_exist;
             |                ^
            3| }

       error: getting status of '/tmp/this_file_does_not_exist': No such file or directory

$ <nix repl exited>
For clarity since when you said "crashes" I expected e.g. a segfault or something: ``` $ nix repl Lix 2.90.0-lixpre20240506-106b959 Type :? for help. nix-repl> test = import ./test.nix nix-repl> test.someImport.<tab>error: … while evaluating the attribute 'someImport' at /tmp/test.nix:2:3: 1| { 2| someImport = import ./this_file_does_not_exist; | ^ 3| } … while calling the 'import' builtin at /tmp/test.nix:2:16: 1| { 2| someImport = import ./this_file_does_not_exist; | ^ 3| } error: getting status of '/tmp/this_file_does_not_exist': No such file or directory $ <nix repl exited> ```
Member

Also reproduces in Nix 2.18.2 and 2.22.1.

Also reproduces in Nix 2.18.2 and 2.22.1.
Author
Member

I'd consider the nix repl exiting a crash in this case since it doesn't with other faulty code.

I'd consider the nix repl exiting a crash in this case since it doesn't with other faulty code.
Member
https://gerrit.lix.systems/c/lix/+/1189
Sign in to join this conversation.
No milestone
No project
No assignees
2 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#340
No description provided.