dan-t / cabal-bounds

Set the version bounds of dependencies in a cabal file
Other
66 stars 7 forks source link

No newline at end of file in generated .cabal #4

Closed patrikja closed 9 years ago

patrikja commented 9 years ago

The generated .cabal file should have a newline to terminate the last line. (To avoid problems with diff, etc.). I'm not sure if the printing is done in cabal-bounds or in Cabal where this recent patch seems to be the fix in generation of initial .cabal files: https://github.com/haskell/cabal/commit/0124d9bd0b565b0a81140586476cd6b32adf59c2

Kind regards, Patrik PS. Some background: http://stackoverflow.com/questions/729692/why-should-files-end-with-a-newline

dan-t commented 9 years ago

Hi Patrik,

the printing is done by the Cabal function Distribution.PackageDescription.PrettyPrint.showGenericPackageDescription. Are you sure that the problem still persists with Cabal 1.22.0.0?

I just output a Cabal file and the last line seems to end with a newline.

Greetings, Daniel

patrikja commented 9 years ago

You are right - Cabal 1.22.0.0 has a better pretty-printer which fixes the newline problem for cabal-bounds. So this issue can be closed.

It is still a problem for me, though, because my machine at work uses lts-1.2 (which has Cabal-1.18: http://www.stackage.org/snapshot/lts-1.2/package/Cabal-1.18.1.5 ).

Fortunately I can install the more recent Cabal + cabal-bounds at home. Thanks for a nice tool.

dan-t commented 9 years ago

It is still a problem for me, though, because my machine at work uses lts-1.2 (which has Cabal-1.18: http://www.stackage.org/snapshot/lts-1.2/package/ Cabal-1.18.1.5 ).

If you could tell me which Cabal version exactly added the newline, then I could conditionally add a newline for the previous versions.

Fortunately I can install the more recent Cabal + cabal-bounds at home. Thanks for a nice tool.

Nice to hear, that you like it. :)

patrikja commented 9 years ago

I have done some experiments (see below) but I would suggest to insert this easy fix in a suitable place:

ensureLastIsNewline xs = if last xs == '\n' then xs else xs++"\n"

Experiments: I've tried to git bisect run towards the Cabal commit where the newline behaviour was fixed but too many github-commit-versions of Cabal fail to install in my envoronment. I have also tried to install a few versions "by hand" but that is too time-consuming. At least I know 1.18.1.5 and 1.20.0.0 has the "no newline at end of file" problem.

dan-t commented 9 years ago

cabal-bounds 0.9.1 should now fix this.

dan-t commented 9 years ago

Unfortunately cabal-bounds 0.9.1 is broken, I will try to release 0.9.2 this evening.