Skip to content

SetupHooks: couldn't match expected type "Cabal-syntax-3.16.0.0:A" with actual type "Cabal-syntax-3-16.0.0:A" #11331

@jorisdral

Description

@jorisdral

Describe the bug

When compiling a SetupHooks module, GHC fails to compile with an error that two types from the Cabal-syntax (or Cabal) library can't be matched even though they are reported to be exactly the same.

SetupHooks.hs:100:30: error: [GHC-83865]
    • Couldn't match type ‘ModuleName’
                     with ‘Cabal-syntax-3.16.0.0:Distribution.ModuleName.ModuleName’
      Expected: [Cabal-syntax-3.16.0.0:Distribution.ModuleName.ModuleName]
        Actual: [ModuleName]
      NB: ‘Cabal-syntax-3.16.0.0:Distribution.ModuleName.ModuleName’
            is defined in ‘Distribution.ModuleName’
                in package ‘Cabal-syntax-3.16.0.0’
          ‘ModuleName’
            is defined in ‘Distribution.ModuleName’
                in package ‘Cabal-syntax-3.16.0.0’
    • In the expression: getModuleNames v
      In a record update at fields ‘otherModules’, ‘installIncludes’,
      with type constructor ‘BuildInfo’
      and data constructor ‘BuildInfo’.
      In the expression:
        emptyBuildInfo
          {otherModules = getModuleNames v,
           installIncludes = [versionsHeaderPath]}
    |
100 |               otherModules = getModuleNames v
    |                           

emptyBuildInfo is coming from the Cabal-hooks library, while the ModuleName type we use in the SetupHooks module is imported from the Cabal-syntax library. If this compiler error is showing here, then that might indicate that we're depending on two different builds of the same Cabal-syntax library in the cabal store. One that Cabal-hooks was built with, and a separate one that we build SetupHooks with. Is there a bug in dependency resolution for the setup-hooks component, perhaps?

I've also noticed that I can't put Cabal-syntax in the build-depends field for the custom-setup component in the cabal file, or I'll get:

SetupHooks.hs:9:1: error:
    Ambiguous module name ‘Distribution.ModuleName’:
      it was found in multiple packages:
      Cabal-syntax-3.16.0.0 Cabal-syntax-3.16.0.0
  |
9 | import           Distribution.ModuleName

To Reproduce

The issue presented itself only on my local system on commit 507994f of the haskell-cryptography/botan

Unfortunately, I have no way to reproduce this easily. With a clean environment (empty store, new ghcup install, empty dist-newstyle) this bug does not present itself again. This is also visible from the GitHub actions CI that succeeds on commit 507994f.

Expected behavior

No type mismatches like this should be reported.

System information

  • Ubuntu 22.04
  • cabal-3-16.0.0
  • ghc-9.6.7

Additional context

A full log of GHC's output
cabal build all --keep-going
Cleared directory 'alternatives/tools/c2hs'
Submodule 'alternatives/c2hs' (https://github.com/haskell/c2hs.git) unregistered for path 'alternatives/tools/c2hs'
Cleared directory 'alternatives/tools/hsc2hs'
Submodule 'alternatives/hsc2hs' (https://github.com/haskell/hsc2hs.git) unregistered for path 'alternatives/tools/hsc2hs'
Cleared directory 'examples/botan/botan'
Submodule 'examples/botan/botan' (https://github.com/randombit/botan) unregistered for path 'examples/botan/botan'
Cleared directory 'examples/c-minisat/minisat-c-bindings'
Submodule 'examples/c-minisat/minisat-c-bindings' (https://github.com/niklasso/minisat-c-bindings.git) unregistered for path 'examples/c-minisat/minisat-c-bindings'
Cleared directory 'examples/c-qrcode/QR-Code-generator'
Submodule 'examples/c-qrcode/QR-Code-generator' (https://github.com/nayuki/QR-Code-generator.git) unregistered for path 'examples/c-qrcode/QR-Code-generator'
From https://github.com/well-typed/hs-bindgen
 * branch              1c4d8052ee8402ea31938d39134a4e8c0145ec3f -> FETCH_HEAD
HEAD is now at 1c4d8052 Merge pull request #1293 from well-typed/jdral/fix-extra-src-files
Submodule 'alternatives/c2hs' (https://github.com/haskell/c2hs.git) registered for path 'alternatives/tools/c2hs'
Submodule 'alternatives/hsc2hs' (https://github.com/haskell/hsc2hs.git) registered for path 'alternatives/tools/hsc2hs'
Submodule 'examples/botan/botan' (https://github.com/randombit/botan) registered for path 'examples/botan/botan'
Submodule 'examples/c-minisat/minisat-c-bindings' (https://github.com/niklasso/minisat-c-bindings.git) registered for path 'examples/c-minisat/minisat-c-bindings'
Submodule 'examples/c-qrcode/QR-Code-generator' (https://github.com/nayuki/QR-Code-generator.git) registered for path 'examples/c-qrcode/QR-Code-generator'
Cloning into '/.../dist-newstyle/src/hs-bindgen-0775302f5e492d706074f363b8a286f26fea334b88e237936950f017c92b9840/alternatives/tools/c2hs'...
Cloning into '/.../dist-newstyle/src/hs-bindgen-0775302f5e492d706074f363b8a286f26fea334b88e237936950f017c92b9840/alternatives/tools/hsc2hs'...
Cloning into '/.../dist-newstyle/src/hs-bindgen-0775302f5e492d706074f363b8a286f26fea334b88e237936950f017c92b9840/examples/botan/botan'...
Cloning into '/.../dist-newstyle/src/hs-bindgen-0775302f5e492d706074f363b8a286f26fea334b88e237936950f017c92b9840/examples/c-minisat/minisat-c-bindings'...
Cloning into '/.../dist-newstyle/src/hs-bindgen-0775302f5e492d706074f363b8a286f26fea334b88e237936950f017c92b9840/examples/c-qrcode/QR-Code-generator'...
Submodule path 'alternatives/tools/c2hs': checked out '6f699f611b8123219ec521f04e1902d4f0f12711'
Submodule path 'alternatives/tools/hsc2hs': checked out 'b1fcea0bf0fbd22f00729cf6479129e8f78ce0d7'
Submodule path 'examples/botan/botan': checked out '07e1cfe0a06b224bbb37ad534736924931184246'
Submodule path 'examples/c-minisat/minisat-c-bindings': checked out '2f137cbedc7a1a0ecd4117baaf84a005c2045134'
Submodule path 'examples/c-qrcode/QR-Code-generator': checked out '720f62bddb7226106071d4728c292cb1df519ceb'
Entering 'alternatives/tools/c2hs'
Entering 'alternatives/tools/hsc2hs'
Entering 'examples/botan/botan'
Entering 'examples/c-minisat/minisat-c-bindings'
Entering 'examples/c-qrcode/QR-Code-generator'
Resolving dependencies...
Build profile: -w ghc-9.6.7 -O1
In order, the following will be built (use -v for more details):
 - botan-bindings-0.1.0.0 (lib:botan-bindings) (cannot read state cache)
 - botan-low-0.0.2.0 (lib) (cannot read state cache)
 - botan-low-0.0.2.0 (test:test) (first run)
 - botan-low-0.0.2.0 (bench:botan-low-bench) (first run)
 - botan-0.1.0.0 (lib) (first run)
[1 of 3] Compiling SetupHooks       ( SetupHooks.hs, /.../dist-newstyle/build/x86_64-linux/ghc-9.6.7/botan-bindings-0.1.0.0/setup/SetupHooks.o ) [Distribution.Types.LocalBuildConfig package changed]

SetupHooks.hs:70:41: error: [GHC-83865]
    • Couldn't match expected type ‘PackageBuildDescr.PackageBuildDescr’
                  with actual type ‘SetupHooks.PackageBuildDescr’
      NB: ‘PackageBuildDescr.PackageBuildDescr’
            is defined in ‘Distribution.Types.LocalBuildConfig’
                in package ‘Cabal-3.16.0.0’
          ‘SetupHooks.PackageBuildDescr’
            is defined in ‘Distribution.Types.LocalBuildConfig’
                in package ‘Cabal-3.16.0.0’
    • In the first argument of ‘PackageBuildDescr.configFlags’, namely
        ‘pbd’
      In the second argument of ‘($)’, namely
        ‘PackageBuildDescr.configFlags pbd’
      In the expression:
        ConfigFlags.configCommonFlags $ PackageBuildDescr.configFlags pbd
   |
70 |         $ PackageBuildDescr.configFlags pbd
   |                                         ^^^

SetupHooks.hs:86:85: error: [GHC-83865]
    • Couldn't match expected type ‘Distribution.Types.ComponentName.ComponentName’
                  with actual type ‘ComponentName’
      NB: ‘Distribution.Types.ComponentName.ComponentName’
            is defined in ‘Distribution.Types.ComponentName’
                in package ‘Cabal-syntax-3.16.0.0’
          ‘ComponentName’
            is defined in ‘Distribution.Types.ComponentName’
                in package ‘Cabal-syntax-3.16.0.0’
    • In the first argument of ‘showComponentName’, namely ‘compName’
      In the second argument of ‘printf’, namely
        ‘(showComponentName compName)’
      In a stmt of a 'do' block:
        printf
          "Running pre-configure-component-hook for '%s'\n"
          (showComponentName compName)
   |
86 |         printf "Running pre-configure-component-hook for '%s'\n" (showComponentName compName)
   |                                                                                     ^^^^^^^^

SetupHooks.hs:89:80: error: [GHC-83865]
    • Couldn't match expected type ‘Distribution.Types.ComponentName.ComponentName’
                  with actual type ‘ComponentName’
      NB: ‘Distribution.Types.ComponentName.ComponentName’
            is defined in ‘Distribution.Types.ComponentName’
                in package ‘Cabal-syntax-3.16.0.0’
          ‘ComponentName’
            is defined in ‘Distribution.Types.ComponentName’
                in package ‘Cabal-syntax-3.16.0.0’
    • In the first argument of ‘showComponentName’, namely ‘compName’
      In the second argument of ‘printf’, namely
        ‘(showComponentName compName)’
      In a stmt of a 'do' block:
        printf
          "No pre-configure-component-hook for '%s'\n"
          (showComponentName compName)
   |
89 |         printf "No pre-configure-component-hook for '%s'\n" (showComponentName compName)
   |                                                                                ^^^^^^^^

SetupHooks.hs:100:30: error: [GHC-83865]
    • Couldn't match type ‘ModuleName’
                     with ‘Cabal-syntax-3.16.0.0:Distribution.ModuleName.ModuleName’
      Expected: [Cabal-syntax-3.16.0.0:Distribution.ModuleName.ModuleName]
        Actual: [ModuleName]
      NB: ‘Cabal-syntax-3.16.0.0:Distribution.ModuleName.ModuleName’
            is defined in ‘Distribution.ModuleName’
                in package ‘Cabal-syntax-3.16.0.0’
          ‘ModuleName’
            is defined in ‘Distribution.ModuleName’
                in package ‘Cabal-syntax-3.16.0.0’
    • In the expression: getModuleNames v
      In a record update at fields ‘otherModules’, ‘installIncludes’,
      with type constructor ‘BuildInfo’
      and data constructor ‘BuildInfo’.
      In the expression:
        emptyBuildInfo
          {otherModules = getModuleNames v,
           installIncludes = [versionsHeaderPath]}
    |
100 |               otherModules = getModuleNames v
    |                              ^^^^^^^^^^^^^^^^

SetupHooks.hs:101:34: error: [GHC-83865]
    • Couldn't match type: DUP.SymbolicPathX
                             DUP.OnlyRelative Include File
                     with: Cabal-syntax-3.16.0.0:Distribution.Utils.Path.SymbolicPathX
                             Cabal-syntax-3.16.0.0:Distribution.Utils.Path.OnlyRelative
                             Cabal-syntax-3.16.0.0:Distribution.Utils.Path.Include
                             Cabal-syntax-3.16.0.0:Distribution.Utils.Path.File
      Expected: Cabal-syntax-3.16.0.0:Distribution.Utils.Path.RelativePath
                  Cabal-syntax-3.16.0.0:Distribution.Utils.Path.Include
                  Cabal-syntax-3.16.0.0:Distribution.Utils.Path.File
        Actual: RelativePath Include File
      NB: ‘Cabal-syntax-3.16.0.0:Distribution.Utils.Path.SymbolicPathX’
            is defined in ‘Distribution.Utils.Path’
                in package ‘Cabal-syntax-3.16.0.0’
          ‘DUP.SymbolicPathX’
            is defined in ‘Distribution.Utils.Path’
                in package ‘Cabal-syntax-3.16.0.0’
    • In the expression: versionsHeaderPath
      In the expression: [versionsHeaderPath]
      In a record update at fields ‘otherModules’, ‘installIncludes’,
      with type constructor ‘BuildInfo’
      and data constructor ‘BuildInfo’.
    |
101 |             , installIncludes = [versionsHeaderPath]
    |                                  ^^^^^^^^^^^^^^^^^^
Error: [Cabal-7125]
Failed to build botan-bindings-0.1.0.0 (which is required by test:test from botan-low-0.0.2.0, bench:botan-low-bench from botan-low-0.0.2.0 and others). The failure occurred during the configure step.

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