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

Improve "Cannot read .cabal file inside ..." errors #10647

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

9999years
Copy link
Collaborator

@9999years 9999years commented Dec 18, 2024

This error message was very confusing -- it doesn't tell you what .cabal file it's looking for or why it cannot read the .cabal file. (Did it fail to parse the .tar archive itself? Did parsing the .cabal file fail? If so, why?)

This patch improves the error message to include the name of the .cabal file being searched for. Additionally, parse errors and warnings are printed, as are format failures in the tarball itself.

I ran into this error while I was writing tests for Cabal and it confused the hell out of me; this is an expanded version of the changes I made to help debug that failure.

  • Tests have been added (Ask for help if you don’t know how to write them)
    • Manual QA notes have been added
  • A changelog entry has been added in changelog.d/pr-YOUR_PR_NUMBER
  • Documentation has been updated
  • Haddock comments for new top-level definitions have been added
  • base and third-party library imports use qualified imports or explicit import lists
  • Commit messages are formatted nicely
  • Post-merge: Backports for older Cabal release branches have been created

Copy link
Collaborator

@geekosaur geekosaur left a comment

Choose a reason for hiding this comment

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

Can we have (a) a PR template and (b) a changelog entry, since this is user visible? Otherwise, nice.

This error message was very confusing -- it doesn't tell you what
`.cabal` file it's looking for or why it cannot read the `.cabal` file.
(Did it fail to parse the `.tar` archive itself? Did parsing the
`.cabal` file fail? If so, why?)

This patch improves the error message to include the name of the
`.cabal` file being searched for. Additionally, parse errors and
warnings are printed, as are format failures in the tarball itself.

I ran into this error while I was writing tests for Cabal and it
confused the hell out of me; this is an expanded version of the changes
I made to help debug that failure.
@@ -1615,7 +1616,7 @@ readSourcePackageCabalFile verbosity pkgfilename content =
case runParseResult (parseGenericPackageDescription content) of
(warnings, Right pkg) -> do
unless (null warnings) $
info verbosity (formatWarnings warnings)
warn verbosity (formatWarnings warnings)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does anyone know why this wasn't warn already?

assertFailure $ "unexpected: " ++ needle
where output = resultOutput result

assertOutputMatches :: MonadIO m => WithCallStack (String -> Result -> m ())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a couple test helpers.

Copy link
Collaborator

@ulysses4ever ulysses4ever left a comment

Choose a reason for hiding this comment

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

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants