I have the following import in a haskell file. I'm using cabal.
import Network.Wai (Application, Response, rawPathInfo, responseFile, responseLBS, requestBody)
But I'm getting this error when I try to build the file:
Error: Ambiguous module name ‘Network.Wai’:
it was found in multiple packages: wai-3.2.2.1 wai-3.2.2.1
Note that the multiple packages are exactly the same. Something like -XPackageImports doesn't work here, because for some reason the same package is installed twice.
I opened up /Users/<user>/.cabal/store/ghc-8.6.5/package.db
and sure enough, there were two "w" (wai) packages with the same version but different hashes. I deleted one and this didn't fix it.
In my case, it was the Data.IP that was ambiguous and it showed 2 same versions of iproute.
I read in https://cabal.readthedocs.io/en/3.4/nix-local-build.html that you can safely delete the store folder. So I ran the below commands.
rm -rf ~/.cabal/store
cabal build
Then my problem went away. This might be useful to anyone else struggling with this issue.