Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ambiguous module name Distribution.PackageDescription #5886

Merged
merged 1 commit into from
Sep 26, 2022
Merged

Conversation

mpilgrem
Copy link
Member

Using Stack 2.9.1 to build a package with a dependency on Cabal and process and:

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.

  • Any changes that could be relevant to users have been recorded in ChangeLog.md.
  • The documentation has been updated, if necessary

Please also shortly describe how you tested your change. Bonus points for added tests! Tested by building and using Stack.

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.
@ulysses4ever
Copy link

For the record, another way to work around it is described here: https://hackage.haskell.org/package/Cabal-syntax-3.6.0.0

@mpilgrem
Copy link
Member Author

Hello @ulysses4ever. Did you have in mind the Cabal flag Cabal-syntax? As Stack compiles StackSetupShim directly with GHC (see Stack.Build.Execute.getSetupExe and the line withWorkingDir (toFilePath tmpdir) $ proc (toFilePath compilerPath) args (\pc0 -> do) I could not work out how Cabal flags would help.

@ulysses4ever
Copy link

Hey there! Indeed, I didn't account for the way Stack works at all. Btw, very clever solution with the package imports!

Apologies for the noise and all the best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants