Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

WIP: Improve error messaging for invalid recipe files #101

Merged
merged 4 commits into from
Jul 20, 2021

Conversation

zainab-ali
Copy link

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.

Copy link
Owner

@akirak akirak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making this PR.

The change looks good, so I will merge it once you consider it ready. I have made a trivial suggestion on the style.

It turns out I didn't reformat the code properly, so I applied nixpkg-fmt on all files. I think it's the standard formatter for Nix at present, so I don't mind it reformats the entire file.

nix/copySource.nix Show resolved Hide resolved
@zainab-ali
Copy link
Author

Thanks! I'm now happy with the PR.

@akirak akirak merged commit bb64b07 into akirak:v4 Jul 20, 2021
@akirak
Copy link
Owner

akirak commented Jul 20, 2021

Thank you for the contribution!

akirak added a commit that referenced this pull request Jul 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants