Skip to content
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

repl: do not crash when tab-completing import errors #10778

Merged
merged 2 commits into from
May 27, 2024

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented May 25, 2024

Motivation

$ cat /tmp/foo.nix
{
  someImport = import ./this_file_does_not_exist;
}
$ ./src/nix/nix repl --file /tmp/foo.nix
warning: unknown experimental feature 'repl-flake'
Nix 2.23.0pre20240517_dirty
Type :? for help.
Loading installable ''...
Added 1 variables.
nix-repl> someImport.<TAB>

Context

Original bug report: https://git.lix.systems/lix-project/lix/issues/340
Fix has been adapted from https://gerrit.lix.systems/c/lix/+/1189

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Mic92 and others added 2 commits May 25, 2024 23:06
This allows better error handling by catching this error in particular.
File not found while importing is not currently caught by the tab-completion handler.

Original bug report: https://git.lix.systems/lix-project/lix/issues/340
Fix has been adapted from https://gerrit.lix.systems/c/lix/+/1189

Example crash:

$ cat /tmp/foo.nix
{
  someImport = import ./this_file_does_not_exist;
}
$ ./src/nix/nix repl --file /tmp/foo.nix
warning: unknown experimental feature 'repl-flake'
Nix 2.23.0pre20240517_dirty
Type :? for help.
Loading installable ''...
Added 1 variables.
nix-repl> someImport.<TAB>
@Mic92 Mic92 requested a review from edolstra as a code owner May 25, 2024 21:17
@github-actions github-actions bot added the repl The Read Eval Print Loop, "nix repl" command and debugger label May 25, 2024
@Mic92 Mic92 changed the title Safer tab completion repl: do not crash when tab-completing import errors May 25, 2024
@Ericson2314
Copy link
Member

Ericson2314 commented May 27, 2024

Thanks @Mic92, I'll add a test oh this is really hard to test!

@Ericson2314 Ericson2314 merged commit aa4a292 into NixOS:master May 27, 2024
10 checks passed
@Mic92 Mic92 deleted the safer-tab-completion branch May 27, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl The Read Eval Print Loop, "nix repl" command and debugger
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants