Skip to content

Setup.hs depends on parsec, but doesn't declare it #5391

Open

Description

@peti

The Cabal.cabal file has to declare parsec as a dependency of the setup script. This problem exists in current versions of master as well as in the 2.2.0.1 release.

$ ghc --make Setup.hs
[  1 of 217] Compiling Distribution.Compat.Binary ( Distribution/Compat/Binary.hs, Distribution/Compat/Binary.o )
[  2 of 217] Compiling Distribution.Compat.Directory ( Distribution/Compat/Directory.hs, Distribution/Compat/Directory.o )
[  3 of 217] Compiling Distribution.Compat.Exception ( Distribution/Compat/Exception.hs, Distribution/Compat/Exception.o )
[  4 of 217] Compiling Distribution.Compat.Internal.TempFile ( Distribution/Compat/Internal/TempFile.hs, Distribution/Compat/Internal/TempFile.o )
[  5 of 217] Compiling Distribution.Compat.Map.Lazy ( Distribution/Compat/Map/Lazy.hs, Distribution/Compat/Map/Lazy.o )
[  6 of 217] Compiling Distribution.Compat.Map.Strict ( Distribution/Compat/Map/Strict.hs, Distribution/Compat/Map/Strict.o )
[  7 of 217] Compiling Distribution.Compat.MonadFail ( Distribution/Compat/MonadFail.hs, Distribution/Compat/MonadFail.o )
[  8 of 217] Compiling Distribution.Compat.Newtype ( Distribution/Compat/Newtype.hs, Distribution/Compat/Newtype.o )
[  9 of 217] Compiling Distribution.Compat.Semigroup ( Distribution/Compat/Semigroup.hs, Distribution/Compat/Semigroup.o )
[ 10 of 217] Compiling Distribution.Compat.Stack ( Distribution/Compat/Stack.hs, Distribution/Compat/Stack.o )
[ 11 of 217] Compiling Distribution.Compat.Prelude ( Distribution/Compat/Prelude.hs, Distribution/Compat/Prelude.o )
[ 12 of 217] Compiling Distribution.Compat.ReadP ( Distribution/Compat/ReadP.hs, Distribution/Compat/ReadP.o )
[ 13 of 217] Compiling Distribution.Compat.Parsing ( Distribution/Compat/Parsing.hs, Distribution/Compat/Parsing.o )

Distribution/Compat/Parsing.hs:61:1: error:
    Could not find module ‘Text.Parsec’
    Use -v to see a list of the files searched for.
   |
61 | import qualified Text.Parsec as Parsec
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Activity

  1. hvr commented on Jun 23, 2018

    @hvr
    Member

    @peti there's not much we can do here; pkg:Cabal is a build-type: Simple package so by definition its contained Setup.hs is supposed to be redundant, and thus there's also no setup-depends; and such a Setup.hs file is supposed to be compatible w/ any lib:Cabal version. The special case of bootstrapping lib:Cabal w/o having any lib:Cabal pre-installed is very special (because, the original CABAL specification in fact demands that every compiler environment comes with a lib:Cabal file pre-installed!), and so this has to be treated manually by packagers of Haskell environments (which themselves constitute a special case).

  2. peti commented on Jul 19, 2018

    @peti
    CollaboratorAuthor

    Why does Cabal have to be a build-type: Simple package? I mean, those setup dependencies just exist. It's a matter of fact. So why not declare them?

  3. phadej commented on Jul 19, 2018

    @phadej
    Collaborator

    Cabal is build-type: Simple package. I think because we have hs-source-dirs: ., the stuff is picked up which shouldn't. I d on't remember why we didn't move sources under src/ , IIRC there was some good reason too. Maybe it was exactly bootstrapping (though, couldn't we then use -isrc ?)

  4. hvr commented on Jul 19, 2018

    @hvr
    Member

    Long time ago, cabal was build-type: Custom, but everyone (and even more so now w/ nix-style builds in combination with custom-setup stanzas which happily recompile multiple lib:Cabal versions even within the same build-plan...) had to pay twice the build-time (which is no joke as lib:Cabal is likely in the top percentile of build-time length for Hackage packages) for lib:Cabal; so this was changed already back in 2015 via #2847 / #2845, and then there also was also the #3003 issue lateron.

    I mean, those setup dependencies just exist.

    I don't agree here; the code in Setup.hs per-se does not require any depedencies (besides base and Cabal + transitive deps)!

    import Distribution.Simple
    main :: IO ()
    main = defaultMain

    If you compile it with ghc -i --make Setup.hs it will work essentially everywhere lib:base and lib:Cabal are exposed! Maybe we should go back to moving everything into src/ sub-folder and use hs-source-dirs: src to make this more obvious/explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions