Improve error message for parsing errors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.5k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 82
Description
Summary
When encountering an invalid character during parsing, spack should give the user some indication of where the error lies.
Rationale
Being new to writing spack recipes, my new recipe included the line
depends_on('cuda >=10.2', when='+cuda')
which is not the correct way of expressing version range.
The corresponding error message was
$ spack install mypackage %intel +openmp
==> Error: Invalid character
which did not tell me which file was affected, nor which line / string was the problem and made it very difficult to track down.
Adding -v or --show-log-on-error did not lead to a more verbose error message.
Description
For example, instead of
https://github.com/spack/spack/blob/8d118104c79bca646b193f84857b75b7f54359df/lib/spack/spack/parse.py#L80
do something like
raise LexError(f"Invalid character in word '{word}'", word, word.index(remainder))
(or make sure to include the metadata of the LexError when displaying the exception).
Additional information
spack --version
0.17.1-1249-8a8b01328b
General information
- I have run
spack --versionand reported the version of Spack - I have searched the issues of this repo and believe this is not a duplicate
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/spack/spack/parse.py at the linked LexError handling and inspect how parsing exceptions are displayed for the shown spack install command. Done means an invalid character error identifies the affected file and the relevant line or string, with useful LexError metadata included in the output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100