dfithian / prune-juice

Prune unused Haskell dependencies.
MIT License
48 stars 4 forks source link

`prune-juice --apply` will empty the cabal file if parsing failed #17

Closed ksqsf closed 2 years ago

dfithian commented 2 years ago

Can you please provide an example of the command you ran and your cabal file

ksqsf commented 2 years ago

Ah, so it's trickier than I thought. I tried to trim the cabal file a bit but even very small changes (like removing synopsis line) would make it parse successfully.

To reproduce, I just ran prune-juice --apply and it would report Failed to parse cabal sections for ./ksqsf-services.cabal due to ParseErrorBundle. Then answer y to every question and the cabal file would be gone.

Failed to parse cabal sections for ./ksqsf-services.cabal due to ParseErrorBundle {bundleErrors = TrivialError 3232 (Just EndOfInput) (fromList [Label ('e' :| "nd of line")]) :| [], bundlePosState = PosState {pstateInput = "<the whole file>", pstateOffset = 0, pstateSourcePos = SourcePos {sourceName = "", sourceLine = Pos 1, sourceColumn = Pos 1}, pstateTabWidth = Pos 8, pstateLinePrefix = ""}}

My cabal file is here, the repo of which unfortunately cannot be made public at the moment. Hope it helps.

edit: I've found the reason. This file is not ended with an EOL.

dfithian commented 2 years ago

Aha! Good find. https://github.com/dfithian/prune-juice/pull/18. Please let me know if that fixes your issue.