user29612357
user29612357

Reputation: 1

Removing ambiguous packages in Haskell

I originally had Data.Matrix installed via cabal install --lib matrix. For some testing, I needed to reinstall the library with profiling, which I did via cabal install --lib matrix --enable-profiling.

However, now when I try to compile my code, I get this error:

app/MainEquations.hs:16:1: error:
    Ambiguous module name ‘Data.Matrix’:
      it was found in multiple packages:
      matrix-0.3.6.3 matrix-0.3.6.3 matrix-0.3.6.3
   |
16 | import Data.Matrix
   | ^^^^^^^^^^^^^^^^^^

When I try to look at the instances of matrix that have been installed with ghc-pkg list matrix, I get:

/home/.ghcup/ghc/9.4.8/lib/ghc-9.4.8/lib/package.conf.d
    (no packages)

/home/.ghc/aarch64-darwin-9.4.8/package.conf.d
    (no packages)

Due to this, I can't even unregister the duplicate installations. What are other possible solutions?

Upvotes: 0

Views: 65

Answers (1)

Noughtmare
Noughtmare

Reputation: 10685

This is one of many reasons to avoid cabal install --lib.

The cabal install --lib command puts things into ~/.ghc/aarch64-darwin-9.4.8/environments/default (or similar based on your architecture and GHC version). So, removing that should solve some issues.

In the future, I'd suggest sticking to a cabal package or a cabal script.

Upvotes: 3

Related Questions