Cabal v2-install failed

After I used ghcup to install haskell on ubuntu, I got ghc-8.10.7 and cabal-3.6.0. When I run command cabal v2-install primitive , there throwed an error

cabal: Could not resolve dependencies:
[__0] trying: primitive- (user goal)
[__1] next goal: base (dependency of primitive)
[__1] rejecting: base- (conflict: primitive =>
base>=4.5 && <4.13)

When I run command cabal v2-install primitive-, there shows

cabal: Could not resolve dependencies:
[__0] next goal: primitive (user goal)
[__0] rejecting: primitive-, primitive-, primitive-,
primitive-, primitive-, primitive-, primitive-,
primitive-, primitive-0.5, primitive-0.4.1, primitive-,
primitive-0.4, primitive-0.3.1, primitive-0.3, primitive-0.2.1, primitive-0.2,
primitive-0.1, primitive-, primitive-, primitive-,
primitive-0.6 (constraint from user target requires ==
[__0] fail (backjumping, conflict set: primitive)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: primitive

try --allow-newer.

Thank you! there is an error

cabal v2-install primitive --allow-newer
Resolving dependencies...
Downloading  primitive-
Downloaded   primitive-
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - primitive- (lib) (requires build)
Starting     primitive- (lib)
Building     primitive- (lib)

Failed to build primitive-
Build log (
Configuring library for primitive-
Preprocessing library for primitive-
Building library for primitive-
[ 1 of 15] Compiling Control.Monad.Primitive ( Control/Monad/Primitive.hs, dist/build/Control/Monad/Primitive.o, dist/build/Control/Monad/Primitive.dyn_o )
[ 2 of 15] Compiling Data.Primitive.Internal.Compat ( Data/Primitive/Internal/Compat.hs, dist/build/Data/Primitive/Internal/Compat.o, dist/build/Data/Primitive/Internal/Compat.dyn_o )
[ 3 of 15] Compiling Data.Primitive.Array ( Data/Primitive/Array.hs, dist/build/Data/Primitive/Array.o, dist/build/Data/Primitive/Array.dyn_o )

Data/Primitive/Array.hs:694:3: error:
    ‘fail’ is not a (visible) method of class ‘Monad’
694 |   fail _ = empty
    |   ^^^^
cabal: Failed to build primitive- See the build log above for details.

boy that version is old. Do a cabal update first.

I did it,but no use.

can you paste your last error? Last primitive should be and compiles fine with

$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 8.8.4

It is not a compilation problem, but a conflict problem. Above, I tried to install primitive-0.7.2, and the results have been posted above.

Try cabal v2-install primitive- again. It should succeed now that you have run cabal update. If it doesn’t then please post the output of both commands.

1 Like

It might also help to modify or remove the default package environment ~/.ghc/x86_64-...-8.10.7/environments/default and avoid running cabal install --lib, because you will run into these kinds of issues if you do.

Also, cabal install primitive doesn’t really make sense, because primitive doesn’t contain any executables and cabal install is only for executables. If you want to use primitive as a dependency I would recommend making a proper cabal package.

1 Like

Thank you! I have fixed it.

0 days since cabal install incident

1 Like