target / lorri

Your project's nix-env
Apache License 2.0
992 stars 69 forks source link

lorri silently fails when shell.nix doesn't build #467

Open samuela opened 4 years ago

samuela commented 4 years ago

Describe the bug Currently lorri will automatically watch the shell.nix file for changes and rebuild the environment when it is modified. This is really awesome! But unfortunately when shell.nix is edited, but does not build properly -- syntax error, package not found, etc -- there's no indication given to the user that their changes have not been applied...

To Reproduce Steps to reproduce the behavior:

  1. lorri init in a directory.
  2. cd into the directory with direnv to automatically enter into the lorri environment.
  3. Edit shell.nix with a "good" edit, eg. add pkgs.python3.
  4. Go back to the terminal and press enter. Note that now you which python3 gives you a nix path.
  5. Edit shell.nix again, but this time with a "bad" edit, eg. rename to pkgs.python3asdfasdfasdf.
  6. Go back to the terminal and press enter. Notice that behind the scenes lorri attempted to build the environment and failed, but there's no indication of this at all to the user.

Expected behavior An error message.

Metadata

n/a

$ lorri info
error: The following required arguments were not provided:
    --shell-file <nix_file>

USAGE:
    lorri info --shell-file <nix_file>

For more information try --help
$ uname -a
Linux skainswo-X58A-UD3R 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 GNU/Linux

Additional context

n/as

Profpatsch commented 4 years ago

That is a good insight. We could maybe query the daemon in the lorri direnv call (via a command that does not yet exist) and display a warning if the last build failed.

Profpatsch commented 4 years ago

This would work by adding a lorri internal project-status or similar, which returns the required information (e.g. last build crashed), similar to how lorri internal stream-events shows some history at the beginning.

lorri direnv would add a call to lorri internal project-status, which itself would print the warnings. This means every time direnv is invoked (either by the editor or the shell), we get the latest project status and it will be printed.