From 79e61349b5bdba8ed0326f41d6b58b2938cc732c Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Mon, 26 Sep 2022 20:45:26 +0100 Subject: [PATCH] Fix Ambiguous module name `Distribution.PackageDescription` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using Stack 2.9.1 to build a package with a dependency on `Cabal` and `process` and: ~~~yaml resolver: lts-19.25 # GHC 9.0.2 (comes with Cabal-3.4.1.0) extra-deps: - Cabal-3.8.1.0 - Cabal-syntax-3.8.1.0 - process-1.6.15.0 ~~~ yields error: ~~~ process > configure process > [1 of 2] Compiling Main ( C:\Users\mikep\AppData\Local\Temp\stack-d0efe7ccadb373e9\process-1.6.15.0\Setup.hs, C:\Users\mikep\AppData\Local\Temp\stack-d0efe7ccadb373e9\process-1.6.15.0\.stack-work\dist\d53b6a14\setup\Main.o ) process > [2 of 2] Compiling StackSetupShim ( C:\sr\setup-exe-src\setup-shim-Z6RU0evB.hs, C:\Users\mikep\AppData\Local\Temp\stack-d0efe7ccadb373e9\process-1.6.15.0\.stack-work\dist\d53b6a14\setup\StackSetupShim.o ) process > process > C:\sr\setup-exe-src\setup-shim-Z6RU0evB.hs:3:1: error: process > Ambiguous module name ‘Distribution.PackageDescription’: process > it was found in multiple packages: process > Cabal-3.4.1.0 Cabal-syntax-3.8.1.0 process > | process > 3 | import Distribution.PackageDescription (PackageDescription, emptyHookedBuildInfo) process > | ~~~ This is because `StackSetupShim` is compiled with (a) the version of `Cabal` that comes with GHC 9.0.2 and (b) the package database that includes `Cabal-syntax-3.8.1.0`, and both export modules named `Distribution.PackageDescription`. This pull request fixes that problem by specifying that the import of `Distribution.PackageDescription` is to come from the `Cabal` package. --- src/setup-shim/StackSetupShim.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/setup-shim/StackSetupShim.hs b/src/setup-shim/StackSetupShim.hs index 124b58af76..c9c33ffc07 100644 --- a/src/setup-shim/StackSetupShim.hs +++ b/src/setup-shim/StackSetupShim.hs @@ -1,6 +1,7 @@ +{-# LANGUAGE PackageImports #-} module StackSetupShim where import Main -import Distribution.PackageDescription (PackageDescription, emptyHookedBuildInfo) +import "Cabal" Distribution.PackageDescription (PackageDescription, emptyHookedBuildInfo) import Distribution.Simple import Distribution.Simple.Build import Distribution.Simple.Setup (ReplFlags, fromFlag, replDistPref, replVerbosity)