Skip to content
  • Rebecca Turner's avatar
    f86d2d9a
    Improve "Cannot read .cabal file inside ..." errors · f86d2d9a
    Rebecca Turner authored
    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.
    
    Before:
    
    ```
    Error: [Cabal-7046]
    Cannot read .cabal file inside my-lib-1.0.tar.gz
    ```
    
    After:
    
    ```
    Error: In <ROOT>/cabal.dist/repo/my-lib-1.0.tar.gz: Errors encountered when parsing cabal file my-lib-1.0/my-lib.cabal:
    
    my-lib-1.0/my-lib.cabal:4:22: error:
    unexpected Unknown SPDX license identifier: 'puppy'
    
        3 | version:        1.0
        4 | license:        puppy license :)
          |                      ^
    
    my-lib-1.0/my-lib.cabal:5:1: warning:
    Unknown field: "puppy"
    
        4 | license:        puppy license :)
        5 | puppy:          teehee!
          | ^
    Error: [Cabal-7046]
    Failed to read my-lib-1.0/my-lib.cabal from archive <ROOT>/cabal.dist/repo/my-lib-1.0.tar.gz
    ```
    f86d2d9a
    Improve "Cannot read .cabal file inside ..." errors
    Rebecca Turner authored
    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.
    
    Before:
    
    ```
    Error: [Cabal-7046]
    Cannot read .cabal file inside my-lib-1.0.tar.gz
    ```
    
    After:
    
    ```
    Error: In <ROOT>/cabal.dist/repo/my-lib-1.0.tar.gz: Errors encountered when parsing cabal file my-lib-1.0/my-lib.cabal:
    
    my-lib-1.0/my-lib.cabal:4:22: error:
    unexpected Unknown SPDX license identifier: 'puppy'
    
        3 | version:        1.0
        4 | license:        puppy license :)
          |                      ^
    
    my-lib-1.0/my-lib.cabal:5:1: warning:
    Unknown field: "puppy"
    
        4 | license:        puppy license :)
        5 | puppy:          teehee!
          | ^
    Error: [Cabal-7046]
    Failed to read my-lib-1.0/my-lib.cabal from archive <ROOT>/cabal.dist/repo/my-lib-1.0.tar.gz
    ```
Loading