You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cabal cannot upload hs-source-dirs that only have autogen-modules #7348
If a Cabal package has a source directory listed in hs-source-dirs that only contains autogen-modules then the package cannot be uploaded without a workaround. Specifically: cabal sdist will omit the entire source directory when creating the sdist and then cabal upload and/or Hackage rejects the package because the sdist is missing the source directory listed in hs-source-dirs.
… and if you were to try to upload the corresponding sdist to Hackage it would reject the upload, saying that the src directory is missing from the sdist.
If you delete the autogen-modules line then v2-sdist incorporates the directory correctly:
@phadej: In the real example that motivated this we actually have two hs-source-dirs: src and gen. src has our normal source code and gen has generated code. Here is the original configuration that motivated this issue:
@phadej: We generate them out-of-band (using Nix), but include them with the uploaded sdist. Are you saying that if we do that then it's more idiomatic to not classify them as autogen-modules?
If the module source files are in the sdist, then they are not autogen-modules (from Cabal perspective they are not generated - it doesn't care whether it's a human developer or some presdist script creating the source file).
@phadej If the autogen-modules section is missing, I'm unable to build it because cabal-install fails with the following error (cf. awakesecurity/proto3-suite#185)
cabal: sdist of proto3-suite-0.5.0: Error: Could not find module: TestProto
with any suffix:
["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the
module is autogenerated it should be added to 'autogen-modules'.
@fumieval: hi! I lack context. Would you mind opening a new ticket with a repro? E.g., what happens if you add the modules to autogen-modules, what cabal-version you are using, etc.? If we are to permit a class of currently forbidden packages to Hackage, we need a ticket for a discussion involving Hackage maintainers, etc.
If a package lacks autogen-modules, cabal is unable to use the package as source-repository-package. Specifying autogen-modules fixes this problem, but doing so makes the package invalid (i.e rejected by Hackage).
Thank you for the repro. Is it rejected by cabal check and/or cabal sdist as well? cc @ffaf1
A cheap guess: would bumping cabal-version in .cabal file help? (but the error messages in the repro would probably suggest that; I haven't run the repro).
cabal check and cabal sdist pass, however, Hackage rejects the package:
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library
fumieval@Retrofractum target % cabal check
No errors or warnings could be found in the package.
fumieval@Retrofractum target % cabal sdist
Wrote tarball sdist to
/Users/fumieval/herp/hs/cabal-autogen-modules-issue/target/dist-newstyle/sdist/autogen-issue-fumieval-1.0.0.tar.gz
fumieval@Retrofractum target % cabal sdist --list-only
./autogen-issue-fumieval.cabal
fumieval@Retrofractum target % cabal upload dist-newstyle/sdist/autogen-issue-fumieval-1.0.0.tar.gz
hackage.haskell.org username: FumiakiKinoshita
hackage.haskell.org password:
Uploading dist-newstyle/sdist/autogen-issue-fumieval-1.0.0.tar.gz...
Error uploading dist-newstyle/sdist/autogen-issue-fumieval-1.0.0.tar.gz: http
code 400
Error: Invalid package
'hs-source-dirs: src' directory does not exist.
I found a workaround (adding an empty file as one of extra-source-files) so I'm happy as long as the PR gets merged, but cabal check still has a false negative bug.
I think this is an issue with sdist, and we should fix it. It should sdist even an empty directory assuming that the directory is listed in hs-source-dirs.
Reacted by Mikolaj Konarski, Fumiaki Kinoshita, ffaf1 and Ivan Perez, PhD
Activity
phadej commentedon Apr 3, 2021
Why
autogen-modulesare generated in-tree. That doesn't seem right. AFAICSsdistworks right here.Gabriella439 commentedon Apr 3, 2021
@phadej: In the real example that motivated this we actually have two
hs-source-dirs:srcandgen.srchas our normal source code andgenhas generated code. Here is the original configuration that motivated this issue:https://github.com/awakesecurity/proto3-suite/blob/489d5a3450411ebb9cf0ce7c0854b1c3f2f9eb69/proto3-suite.cabal#L107-L113
You still run into the same problem because
genis not bundled in the sdist because it only containsautogen-modulesphadej commentedon Apr 3, 2021
I still don't understand.
How (e.g.)
TestProtomodule is generated inproto3-suiteexample? The package isbuild-type: Simple?You can generate
autogen-modulesonly withbuild-type: Custom, seeI suspect
autogen-modulesin a way which is not really supported. (The main use case isPaths_pkgname, and then custom stuff used by e.g.gi-gtk)Gabriella439 commentedon Apr 4, 2021
@phadej: We generate them out-of-band (using Nix), but include them with the uploaded sdist. Are you saying that if we do that then it's more idiomatic to not classify them as
autogen-modules?phadej commentedon Apr 4, 2021
If the module source files are in the sdist, then they are not
autogen-modules(fromCabalperspective they are not generated - it doesn't care whether it's a human developer or some presdist script creating the source file).Gabriella439 commentedon Apr 4, 2021
Alright, then I'll close this then. This is us misunderstanding
autogen-modulesRemove autogen-modules from `proto3-suite.cabal`
Remove autogen-modules from `proto3-suite.cabal` (#147)
fumieval commentedon Mar 24, 2022
@phadej If the autogen-modules section is missing, I'm unable to build it because cabal-install fails with the following error (cf. awakesecurity/proto3-suite#185)
fumieval commentedon Jun 6, 2022
@phadej Any change you could consider lifting the restriction? I'm not sure what exactly goes wrong if such package is uploaded to Hackage
Mikolaj commentedon Jun 6, 2022
@fumieval: hi! I lack context. Would you mind opening a new ticket with a repro? E.g., what happens if you add the modules to
autogen-modules, whatcabal-versionyou are using, etc.? If we are to permit a class of currently forbidden packages to Hackage, we need a ticket for a discussion involving Hackage maintainers, etc.fumieval commentedon Jun 29, 2022
@Mikolaj hi, sorry for late response. I made a small reproducer: https://github.com/fumieval/cabal-autogen-modules-issue
If a package lacks autogen-modules, cabal is unable to use the package as source-repository-package. Specifying autogen-modules fixes this problem, but doing so makes the package invalid (i.e rejected by Hackage).
Mikolaj commentedon Jun 29, 2022
Thank you for the repro. Is it rejected by
cabal checkand/orcabal sdistas well? cc @ffaf1A cheap guess: would bumping
cabal-versionin .cabal file help? (but the error messages in the repro would probably suggest that; I haven't run the repro).fumieval commentedon Jun 29, 2022
Updating cabal-version didn't help. I made a smaller reproducing example:
https://github.com/fumieval/cabal-autogen-modules-issue/blob/98905bad79d3e25ce765019b791a837e25f690ea/target/autogen-issue-fumieval.cabal
cabal checkandcabal sdistpass, however, Hackage rejects the package:I found a workaround (adding an empty file as one of extra-source-files) so I'm happy as long as the PR gets merged, but
cabal checkstill has a false negative bug.Mikolaj commentedon Jun 29, 2022
[Apologies, wrong window. :D I've deleted the wrong comment.]
gbaz commentedon Jun 29, 2022
I think this is an issue with
sdist, and we should fix it. It shouldsdisteven an empty directory assuming that the directory is listed inhs-source-dirs.ivanperez-keera commentedon Nov 21, 2022
Hitting this bug with a project that I'm trying to put on hackage that is mainly a language library automatically generated from a BNFC grammar.
ivanperez-keera commentedon Nov 21, 2022
I'm working around the issue by creating
.keepempty files and adding them toextra-source-files.Merge branch 'develop-empty-dirs' into develop. Close #65.