Skip to content

cabal init --libandexe should add the library to the build-depends of the executable #7256

Closed
@andreasabel

Description

@andreasabel

cabal-3.5.0.0 seems to have no implicit build-depends of the executable on the library so cabal init should add this.

Here is a reproduction script (from #7253 (comment)), needs PR #7253:

bnfc --version || cabal install BNFC
mkdir -p myparser
cd myparser
echo "Foo. Bar ::= Integer" > Foo.cf
bnfc -o src -d -m Foo.cf
make -C src
mv src/Foo/Test.hs Main.hs
cabal v2-init --libandexe --application-dir=.
cabal v2-build all
cat myparser.cabal

The cabal build fails with errors like

Main.hs:9:1: error:
    Could not load module ‘Foo.Lex’
    It is a member of the hidden package ‘myparser-0.1.0.0’.
    Perhaps you need to add ‘myparser’ to the build-depends in your .cabal file.

Manually adding myparser to the build-depends of the executable stanza fixes the problem.

Except for the warning now emitted by cabal which is obviously a lie:

Warning: The package has an extraneous version range for a dependency on an
internal library: myparser >=0 && ==0.1.0.0. This version range includes the
current package but isn't needed as the current package's library will always
be used.

System information

  • Operating system: macOS
  • cabal: development version (3.5.0.0)
  • ghc 8.10.3

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