akirak / elinter

Nix-based CI and local testing framework for Emacs Lisp projects
GNU General Public License v3.0
18 stars 2 forks source link

WIP: Improve error messaging for invalid recipe files #101

Closed zainab-ali closed 3 years ago

zainab-ali commented 3 years ago

Thank you for an excellent tool!

I recently had a problem that took some time to debug.

When running elinter locally, I had an emacs backup file in my .recipes directory:

[nix-shell:~/elisp/foo]$ ls .recipes/
foo  foo~

This was picked up when running elinter:

Looking for recipes in .recipes...
Found .recipes/foo .recipes/foo~

Linking package source files...

Reusing the previous settings for foo:
foo.el
error: list index 0 is out of bounds, at /nix/store/d5hxq1xqrl93f7si3hrksikvzkdh1q2b-elinter-share/share/elinter/nix/copySource.nix:35:16
(use '--show-trace' to show detailed location information)

The foo~ recipe pointed to a non-existent source file.

The copySource.nix expression takes the head of the source files, aborting with the above out of bounds error if there are no source files:

head (filter isMainFile sourceFiles)

This took me a while to debug - I didn't realize that the error was thrown when processing the foo~ recipe

What do you think about adding a per-recipe logging statement?

This PR prints:

Linking package source files for recipe .recipes/foo~ ...
error: evaluation aborted with the following error message: 'Main elisp file not found for recipe /home/zainab/elisp/foo/.recipes/foo~.'
(use '--show-trace' to show detailed location information)

I'm marking this as a WIP while I figure out what's wrong with my nixpkgs-fmt hook. I assume that the hook shouldn't have reformatted the entire copySources.nix file.

zainab-ali commented 3 years ago

Thanks! I'm now happy with the PR.

akirak commented 3 years ago

Thank you for the contribution!