Giter Club home page Giter Club logo

Comments (6)

ffaf1 avatar ffaf1 commented on June 13, 2024

Works here, cabal HEAD. Works with your .cabal too.

f@x270:/tmp/prova$ cat prova.cabal
cabal-version:   3.0
name:            prova
version:         0.1.0.0
license:         NONE
author:          Francesco Ariis
maintainer:      [email protected]
build-type:      Simple
extra-doc-files: CHANGELOG.md

flag wat

common warnings
    ghc-options: -Wall

executable prova
 import:           warnings
 if flag(wat)
     main-is: bar-foo.hs
 else
     main-is: foo-bar.hs
 build-depends:    base ^>=4.18.1.0
 hs-source-dirs:   app
 default-language: Haskell2010
f@x270:/tmp/prova$ tree app/
app/
├── bar-foo.hs
└── foo-bar.hs

1 directory, 2 files
f@x270:/tmp/prova$ cabal check
Warning: this is a debug build of cabal-install with assertions enabled.
These warnings will likely cause trouble when distributing the package:
Warning: [no-category] No 'category' field.
The following errors will cause portability problems on other environments:
Error: [no-syn-desc] No 'synopsis' or 'description' field.
Error: [license-none] The 'license' field is missing or is NONE.
Error: Hackage would reject this package.
f@x270:/tmp/prova$ cabal build
Warning: this is a debug build of cabal-install with assertions enabled.
Warning: The package list for 'hackage.haskell.org' is 33 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Build profile: -w ghc-9.6.3 -O1
In order, the following will be built (use -v for more details):
 - prova-0.1.0.0 (exe:prova) (first run)
Warning: this is a debug build of cabal-install with assertions enabled.
Configuring executable 'prova' for prova-0.1.0.0...
Warning: this is a debug build of cabal-install with assertions enabled.
Preprocessing executable 'prova' for prova-0.1.0.0...
Building executable 'prova' for prova-0.1.0.0...
[1 of 1] Compiling Main             ( app/bar-foo.hs, /tmp/prova/dist-newstyle/build/x86_64-linux/ghc-9.6.3/prova-0.1.0.0/x/prova/build/prova/prova-tmp/Main.o )
[2 of 2] Linking /tmp/prova/dist-newstyle/build/x86_64-linux/ghc-9.6.3/prova-0.1.0.0/x/prova/build/prova/prova
f@x270:/tmp/prova$ cabal --version
cabal-install version 3.11.0.0
compiled using version 3.11.0.0 of the Cabal library

from cabal.

jwaldmann avatar jwaldmann commented on June 13, 2024

my reproducer for 3.10.2.0 : https://git.imn.htwk-leipzig.de/waldmann/cabal-9659/-/jobs/39798

from cabal.

gbaz avatar gbaz commented on June 13, 2024

Note, this does not appear to be a check error anymore:

Error: cabal: bar-foo.hsfoo-bar.hs doesn't exist

It looks like both sides of the conditional get evaluated and merged in the install command, not the check command. Maybe we're not evaluating conditionals right in that stanza?

from cabal.

ffaf1 avatar ffaf1 commented on June 13, 2024

Thanks for providing the reproducer.

Indeed I mistakenly thought the error was triggered by build/check, but it is not. It is cabal sdist (and cabal install) that fails:

/tmp/cabal-9659 (main)$ cabal --version
cabal-install version 3.11.0.0
compiled using version 3.11.0.0 of the Cabal library
/tmp/cabal-9659 (main)$ cabal sdist
Warning: this is a debug build of cabal-install with assertions enabled.
Ambiguous values for modulePath field: '"bar-foo.hs"' and '"foo-bar.hs"'
CallStack (from HasCallStack):
  error, called at src/Distribution/Types/UnqualComponentName.hs:128:7 in Cabal-syntax-3.11.0.0-inplace:Distribution.Types.UnqualComponentName
/tmp/cabal-9659 (main)$ ~/download/cabal --version
cabal-install version 3.10.2.0
compiled using version 3.10.2.1 of the Cabal library
/tmp/cabal-9659 (main)$ ~/download/cabal sdist
Error: cabal: bar-foo.hsfoo-bar.hs doesn't exist

Offending code is a broken Semigroup instance:

instance Semigroup Executable where
a <> b =
Executable
{ exeName = combineNames a b exeName "executable"
, modulePath = combineNames a b modulePath "modulePath"
, exeScope = combine exeScope
, buildInfo = combine buildInfo
}
where
combine field = field a `mappend` field b

b0cb3d4

which I suspect it is getting called via flattenPackageDescription.

from cabal.

gbaz avatar gbaz commented on June 13, 2024

That sounds right. I was going to suggest we use finalizePD instead of flattenPackageDescription but in fact for sdist at least we really do need both sides of the conditional, since we need to add both to the tarball. We just need to ensure that we accumulate as lists of module names, not strings.

from cabal.

ffaf1 avatar ffaf1 commented on June 13, 2024

#9724 provides a possible workaround using extra-source-file.

from cabal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.