Problem with publishing project/packages

Hello, I am not sure if this is the right place to report/discuss the following issue, but I have been fiddling around with properly publishing a project I am developing in Haskell for quite some time now. I have encountered various difficulties that I would like to share and hear your opinion about, and also your suggestions about what I could improve, and probably also, how the Haskell ecosystem could be improved. First, I use Stack+Hpack to manage `.cabal` files. I know, that this combination has summoned many controversies, but I don't want to spend hours fiddling around in my `.cabal` files and on the version bounds, so decided for this option. I use strict PVP bounds (--pvp-bounds both options), so that at least compilation should be reproducible, albeit only allowing the specific set of library versions present in the Stack resolver. My project does heavy numerical calculations, so I was awaiting the support of LLVM9.0, which will come with GHC 8.10, for a long time. In the meantime, I tried to compile and publish my project in its current state with the newest Stack resolver 15.x with GHC 8.8.3. On my local machine, compilation and the development cycle work reasonably well, but as soon as I try to publish my work, I have serious trouble. First, I encountered an issue with auto generated modules of the packages causing trouble in the `.cabal` files generated by Hpack [1]. I think this is because the Cabal specification was improved (i.e., has changed), and new specifications have to be honored. I try to work around the issue by directly specifying the newest Cabal specification 3.0 and by tinkering around with the flags, until Hpack produces files compatible with the newest version of Cabal. Finally, I can create source tarballs with `stack sdist --pvp-bounds both`. However, I cannot upload these tarballs, because somehow, the created `.cabal` files in the source tarballs include dependencies of the following form: `base : {} >= x.y, <= z.a` (or something similar), and Hackage chokes on this form (is this a new syntax? or is it just a bug?). So I think, maybe this is caused by an incompatibility of Stack with my Cabal or cabal-install version, which are newer than the newest ones officially supported by Stack. I had already lost one day of working time at this point. I did not give up, but decided to install a Cabal version officially supported by Stack. Also, I removed all my dependencies on auto-generated modules from the packages and the `.cabal` files, I reverted other changes I had implemented because of the Cabal specification change (for example, reverting all license identifiers). I managed to compile and publish my project on Hackage. However, Hackage is not able to compile the packages and show the documentation (which is what I need most). Because I am going the easy route, and use strict PVP bounds, Hackage cannot compile my packages because they depend on base >= 4.13, and Cabal version 3.0. It took me another hour or so, to find out that the official package repository of Haskell does not support the official base library which has been published over six months ago. From a users point of view, this is unacceptable. I have found some resources about this issue now, but I was not aware of this discrepancy before experiencing it. So my next thought is: "Let's just put it on Stackage, because the best days of Hackage seem to be over...". However, I cannot do that, because my project needs to compile on Hackage in order to be put on Stackage... I guess all this is consequence of using an operating system with up-to-date packages (Arch Linux), and my inherent demand to use the newest compiler, and so on. However, I feel that it is not entirely my fault, the new compiler with the new base libraries should be supported by the official repository, and in a coherent way by the most widely used build tools Cabal and Stack (which uses Hpack by default, by the way). I sincerely apologize for being so harsh, but I am angry at the ecosystem, and angry at myself, because, obviously, I don't know enough to get things done. Thanks for your feedback, it is appreciated! Dominik Schrempf References: [1] https://github.com/sol/hpack/issues/384 [2] In case of interest, the project I am developing is a set of libraries/binaries to be used in evolutionary biology https://github.com/dschrempf/elynx

On Mon, 27 Apr 2020, Dominik Schrempf wrote:
So my next thought is: "Let's just put it on Stackage, because the best days of Hackage seem to be over...". However, I cannot do that, because my project needs to compile on Hackage in order to be put on Stackage...
You only need to _release_ your package on Hackage, it is not required that the Hackage server can build it. Stackage builds packages on its own. If Hackage fails to build your documentation, you can create it yourself and upload it manually: $ cabal haddock --for-hackage --hyperlink-source $ cabal upload --documentation --publish dist/pkg-0.1-docs.tar.gz

Am 27.04.20 um 23:43 schrieb Henning Thielemann:
So my next thought is: "Let's just put it on Stackage, because the best days of Hackage seem to be over...". However, I cannot do that, because my project needs to compile on Hackage in order to be put on Stackage...
You only need to _release_ your package on Hackage, it is not required that the Hackage server can build it. Stackage builds packages on its own.
If Hackage fails to build your documentation, you can create it yourself and upload it manually:
$ cabal haddock --for-hackage --hyperlink-source $ cabal upload --documentation --publish dist/pkg-0.1-docs.tar.gz
Thanks Henning, this was helpful for me as well. I just uploaded the docs for darcs-2.14.3 using your recipe. Note however that for newer cabal-install versions the option names have changed to --haddock-for-hackage and --haddock-hyperlink-source. Cheers Ben

Thank you, I also didn't know that a package release is enough to be added to
Stackage. I was also not aware of the cabal commands creating the documentation
for Hackage.
Nevertheless, I believe that we should improve on developer-friendliness. In the
end, we --- the developers and users --- create and maintain the libraries and
the ecosystem, and we depend on a healthy Haskell ecosystem.
Dominik
Ben Franksen
Am 27.04.20 um 23:43 schrieb Henning Thielemann:
So my next thought is: "Let's just put it on Stackage, because the best days of Hackage seem to be over...". However, I cannot do that, because my project needs to compile on Hackage in order to be put on Stackage...
You only need to _release_ your package on Hackage, it is not required that the Hackage server can build it. Stackage builds packages on its own.
If Hackage fails to build your documentation, you can create it yourself and upload it manually:
$ cabal haddock --for-hackage --hyperlink-source $ cabal upload --documentation --publish dist/pkg-0.1-docs.tar.gz
Thanks Henning, this was helpful for me as well. I just uploaded the docs for darcs-2.14.3 using your recipe.
Note however that for newer cabal-install versions the option names have changed to --haddock-for-hackage and --haddock-hyperlink-source.
Cheers Ben
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

By the way, I just failed building the documentation. This is all wrong :|.
Resolving dependencies...
Build profile: -w ghc-8.8.3 -O1
In order, the following will be built (use -v for more details):
- matrices-0.5.0 (lib) (requires build)
- storable-complex-0.2.3.0 (lib:storable-complex) (requires build)
- hmatrix-0.20.0.0 (lib) (requires build)
- elynx-tools-0.2.2 (lib) (first run)
Starting storable-complex-0.2.3.0 (all, legacy fallback)
Starting matrices-0.5.0 (lib)
Building storable-complex-0.2.3.0 (all, legacy fallback)
Building matrices-0.5.0 (lib)
Failed to build matrices-0.5.0.
Build log (
/home/dominik/.cabal/logs/ghc-8.8.3/matrices-0.5.0-fad3378ef6f4b9b628fbbd797b7c85b4d66179cdfbce76fdac9c0e095f6cd439.log
):
Configuring library for matrices-0.5.0..
Preprocessing library for matrices-0.5.0..
Building library for matrices-0.5.0..
[ 1 of 13] Compiling Data.Matrix.Class.Mutable ( src/Data/Matrix/Class/Mutable.hs, dist/build/Data/Matrix/Class/Mutable.o )
src/Data/Matrix/Class/Mutable.hs:10:1: error:
Could not find module ‘Control.Monad.Primitive’
There are files missing in the ‘primitive-0.7.0.1’ package,
try running 'ghc-pkg check'.
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
10 | import Control.Monad.Primitive (PrimMonad, PrimState)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/Data/Matrix/Class/Mutable.hs:11:1: error:
Could not find module ‘Data.Vector.Generic.Mutable’
There are files missing in the ‘vector-0.12.1.2’ package,
try running 'ghc-pkg check'.
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
11 | import qualified Data.Vector.Generic.Mutable as GM
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dominik Schrempf
Thank you, I also didn't know that a package release is enough to be added to Stackage. I was also not aware of the cabal commands creating the documentation for Hackage.
Nevertheless, I believe that we should improve on developer-friendliness. In the end, we --- the developers and users --- create and maintain the libraries and the ecosystem, and we depend on a healthy Haskell ecosystem.
Dominik
Ben Franksen
writes: Am 27.04.20 um 23:43 schrieb Henning Thielemann:
So my next thought is: "Let's just put it on Stackage, because the best days of Hackage seem to be over...". However, I cannot do that, because my project needs to compile on Hackage in order to be put on Stackage...
You only need to _release_ your package on Hackage, it is not required that the Hackage server can build it. Stackage builds packages on its own.
If Hackage fails to build your documentation, you can create it yourself and upload it manually:
$ cabal haddock --for-hackage --hyperlink-source $ cabal upload --documentation --publish dist/pkg-0.1-docs.tar.gz
Thanks Henning, this was helpful for me as well. I just uploaded the docs for darcs-2.14.3 using your recipe.
Note however that for newer cabal-install versions the option names have changed to --haddock-for-hackage and --haddock-hyperlink-source.
Cheers Ben
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Am 28.04.20 um 13:17 schrieb Dominik Schrempf:
By the way, I just failed building the documentation. This is all wrong :|.
src/Data/Matrix/Class/Mutable.hs:10:1: error: Could not find module ‘Control.Monad.Primitive’ There are files missing in the ‘primitive-0.7.0.1’ package, try running 'ghc-pkg check'. Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 10 | import Control.Monad.Primitive (PrimMonad, PrimState) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Yes, this is either 'cabal haddock' or just 'haddock' doing a front-end compile phase, give or take. This can be extremely annoying when all you want to have are the docs. But it's strange that you can cabal build but not cabal haddock if you get such errors. Which cabal-install version is this? I agree that in general there are some things that could go smoother. I think part of the problem is that the addition of the backpack support has made cabal even more complicated than it already was, while at the same time the newstyle commands were implemented. Both are extremely valuable features but maintaining such a monster must be hard. I am not involved in cabal development at all and know almost nothing about its internal workings, but perhaps things could be improved by making it a bit more modular; i.e. strive for the traditional Unix approach of "do one thing and do it well". Probably easier said then done, though. Today I ran again into a problem I had several times before: compiling Cabal-3.2.* (the library) with ghc-8.2.2 and cabal with default options (including jobs: $ncpu, though it actually used only one cpu) eats all the memory on my machine (8GB, but I had a tor browser and another browser and thunderbird running) so that it completely freezes (no mouse, no keyboard). Had to reboot using sysrq escape hatch. Not funny. I think this is due to use of ghc --make and some very large modules. Thankfully memory use has improved with later ghc versions. Cheers Ben

On Tue, 28 Apr 2020, Ben Franksen wrote:
Today I ran again into a problem I had several times before: compiling Cabal-3.2.* (the library) with ghc-8.2.2 and cabal with default options (including jobs: $ncpu, though it actually used only one cpu) eats all the memory on my machine (8GB, but I had a tor browser and another browser and thunderbird running) so that it completely freezes (no mouse, no keyboard). Had to reboot using sysrq escape hatch. Not funny. I think this is due to use of ghc --make and some very large modules. Thankfully memory use has improved with later ghc versions.
That's why I never use 'jobs: $ncpu' and also oppose to use this as the default setting. [1] There are some modules in packages that frequently eat up all my resources, e.g. I know that building "Cabal the library" is such a package. I remember that I can save memory by aborting compilation and restart it. It seems that GHC may cache too much. But continuing an aborted compilation is not possible for imported packages when using 'cabal install'. Other packages contain big modules automatically created by Template Haskell. [1] https://github.com/haskell/cabal/issues/5776

Am 28.04.20 um 14:12 schrieb Henning Thielemann:
Today I ran again into a problem I had several times before: compiling Cabal-3.2.* (the library) with ghc-8.2.2 and cabal with default options (including jobs: $ncpu, though it actually used only one cpu) eats all the memory on my machine (8GB, but I had a tor browser and another browser and thunderbird running) so that it completely freezes (no mouse, no keyboard). Had to reboot using sysrq escape hatch. Not funny. I think this is due to use of ghc --make and some very large modules. Thankfully memory use has improved with later ghc versions.
That's why I never use 'jobs: $ncpu' and also oppose to use this as the default setting.
Yeah, right. On the other hand, I had a job running that compiles and runs all the tests for darcs for 5 different ghc versions. You want all the cores to run at max in this case to get results before sunset! (Darcs itself is not a small project and takes quite a while to compile with optimizations. I also I did not expect cabal-3.2 to be re-built for ghc-8.2, that was a mistake I made in the cabal file; if I had I would have closely monitored memory use to be ready to kill it).
[1] There are some modules in packages that frequently eat up all my resources, e.g. I know that building "Cabal the library" is such a package. I remember that I can save memory by aborting compilation and restart it. It seems that GHC may cache too much. But continuing an aborted compilation is not possible for imported packages when using 'cabal install'. Other packages contain big modules automatically created by Template Haskell.
Yes. In the past I also had difficulty with vector and with aeson. Cheers Ben

On Tue, 28 Apr 2020, Ben Franksen wrote:
Am 28.04.20 um 14:12 schrieb Henning Thielemann:
[1] There are some modules in packages that frequently eat up all my resources, e.g. I know that building "Cabal the library" is such a package. I remember that I can save memory by aborting compilation and restart it. It seems that GHC may cache too much. But continuing an aborted compilation is not possible for imported packages when using 'cabal install'. Other packages contain big modules automatically created by Template Haskell.
Yes. In the past I also had difficulty with vector and with aeson.
I remember those, too.

On Tue, 28 Apr 2020 at 08:13, Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Tue, 28 Apr 2020, Ben Franksen wrote:
I remember that I can save memory by aborting compilation and restart it. It seems that GHC may cache too much.
I've also experienced this multiple times (e.g., with Qt, which is huge, and with yesod apps). Could this also be indicative of a leak? I sometimes wonder if the developers behind some libraries operate with resources that are far beyond what any of us have or can afford. Ivan

On Tue, 28 Apr 2020, Ivan Perez wrote:
On Tue, 28 Apr 2020 at 08:13, Henning Thielemann
wrote: On Tue, 28 Apr 2020, Ben Franksen wrote:
> I remember that I can save memory by aborting compilation and restart it. It seems that GHC may cache too much.
I've also experienced this multiple times (e.g., with Qt, which is huge, and with yesod apps).
Could this also be indicative of a leak?
sure
I sometimes wonder if the developers behind some libraries operate with resources that are far beyond what any of us have or can afford.
Not only that. Sometimes I want to compile a library on the Raspberry and I cannot add memory to that board.

On Tue, 28 Apr 2020, Dominik Schrempf wrote:
By the way, I just failed building the documentation. This is all wrong :|.
Resolving dependencies... Build profile: -w ghc-8.8.3 -O1 In order, the following will be built (use -v for more details): - matrices-0.5.0 (lib) (requires build) - storable-complex-0.2.3.0 (lib:storable-complex) (requires build) - hmatrix-0.20.0.0 (lib) (requires build) - elynx-tools-0.2.2 (lib) (first run) Starting storable-complex-0.2.3.0 (all, legacy fallback) Starting matrices-0.5.0 (lib) Building storable-complex-0.2.3.0 (all, legacy fallback) Building matrices-0.5.0 (lib)
Failed to build matrices-0.5.0. Build log ( /home/dominik/.cabal/logs/ghc-8.8.3/matrices-0.5.0-fad3378ef6f4b9b628fbbd797b7c85b4d66179cdfbce76fdac9c0e095f6cd439.log ): Configuring library for matrices-0.5.0.. Preprocessing library for matrices-0.5.0.. Building library for matrices-0.5.0.. [ 1 of 13] Compiling Data.Matrix.Class.Mutable ( src/Data/Matrix/Class/Mutable.hs, dist/build/Data/Matrix/Class/Mutable.o )
src/Data/Matrix/Class/Mutable.hs:10:1: error: Could not find module ‘Control.Monad.Primitive’ There are files missing in the ‘primitive-0.7.0.1’ package, try running 'ghc-pkg check'. Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 10 | import Control.Monad.Primitive (PrimMonad, PrimState) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What cabal-install version did you use for this build and what 'build' method did you use, v1-build or v2-build? The message could mean that you are building with profiling but some 'primitive' was installed without profiling. With 'cabal v2-build' (new-build) there should not be a problem, because Cabal should simply build profiling objects when needed. However, for building the documentation you do not need profiling. But then again, profiling was just a guess. It's best you show us your actual command-line and used Cabal version and the package (e.g. repository) that you try to upload.

Maybe I should have been more specific. I can compile the package with `stack
build`, but never built with cabal directly.
My cabal versions are:
+ cabal --version
cabal-install version 3.0.0.0
compiled using version 3.0.1.0 of the Cabal library
The command I use is
cabal build
or
cabal haddock --haddock-for-hackage --haddock-hyperlink-source
v2-build and new-build fail with the error I posted below.
v1-build fails with
Resolving dependencies...
Warning: solver failed to find a solution:
Could not resolve dependencies:
[__0] trying: elynx-tools-0.2.2 (user goal)
[__1] unknown package: matrices (dependency of elynx-tools)
[__1] fail (backjumping, conflict set: elynx-tools, matrices)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: elynx-tools, matrices
Trying configure anyway.
Configuring elynx-tools-0.2.2...
cabal: Encountered missing or private dependencies:
hmatrix -any, matrices -any
The package I try to compile can be found here:
https://github.com/dschrempf/elynx/tree/master/elynx-tools
Thank you for your help!
Dominik
Henning Thielemann
On Tue, 28 Apr 2020, Dominik Schrempf wrote:
By the way, I just failed building the documentation. This is all wrong :|.
Resolving dependencies... Build profile: -w ghc-8.8.3 -O1 In order, the following will be built (use -v for more details): - matrices-0.5.0 (lib) (requires build) - storable-complex-0.2.3.0 (lib:storable-complex) (requires build) - hmatrix-0.20.0.0 (lib) (requires build) - elynx-tools-0.2.2 (lib) (first run) Starting storable-complex-0.2.3.0 (all, legacy fallback) Starting matrices-0.5.0 (lib) Building storable-complex-0.2.3.0 (all, legacy fallback) Building matrices-0.5.0 (lib)
Failed to build matrices-0.5.0. Build log ( /home/dominik/.cabal/logs/ghc-8.8.3/matrices-0.5.0-fad3378ef6f4b9b628fbbd797b7c85b4d66179cdfbce76fdac9c0e095f6cd439.log ): Configuring library for matrices-0.5.0.. Preprocessing library for matrices-0.5.0.. Building library for matrices-0.5.0.. [ 1 of 13] Compiling Data.Matrix.Class.Mutable ( src/Data/Matrix/Class/Mutable.hs, dist/build/Data/Matrix/Class/Mutable.o )
src/Data/Matrix/Class/Mutable.hs:10:1: error: Could not find module ‘Control.Monad.Primitive’ There are files missing in the ‘primitive-0.7.0.1’ package, try running 'ghc-pkg check'. Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 10 | import Control.Monad.Primitive (PrimMonad, PrimState) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What cabal-install version did you use for this build and what 'build' method did you use, v1-build or v2-build?
The message could mean that you are building with profiling but some 'primitive' was installed without profiling. With 'cabal v2-build' (new-build) there should not be a problem, because Cabal should simply build profiling objects when needed. However, for building the documentation you do not need profiling. But then again, profiling was just a guess.
It's best you show us your actual command-line and used Cabal version and the package (e.g. repository) that you try to upload.

Am 28.04.20 um 15:38 schrieb Dominik Schrempf:
Maybe I should have been more specific. I can compile the package with `stack build`, but never built with cabal directly.
My cabal versions are: + cabal --version cabal-install version 3.0.0.0 compiled using version 3.0.1.0 of the Cabal library
The command I use is cabal build or cabal haddock --haddock-for-hackage --haddock-hyperlink-source
v2-build and new-build fail with the error I posted below.
By default cabal uses the ghc that it finds in your PATH. My guess is that this is a different version than that in your stack setup, which means cabal may select some older or newer dependencies as a result. If you have the same ghc, you could look at the versions of the libraries that cabal selects and that give you trouble. Compare them to what your working stack setup uses and adapt the version bounds accordingly in your cabal file. Or perhaps stack can be convinced to write a cabal file that freezes the versions to exactly the set supported by that setup? Cheers Ben
participants (5)
-
Ben Franksen
-
Dominik Schrempf
-
Francesco Ariis
-
Henning Thielemann
-
Ivan Perez