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-0.6.4.0 (user goal)
[__1] next goal: base (dependency of primitive)
[__1] rejecting: base-4.14.3.0/installed-4.14.3.0 (conflict: primitive =>
base>=4.5 && <4.13)

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

cabal: Could not resolve dependencies:
[__0] next goal: primitive (user goal)
[__0] rejecting: primitive-0.6.4.0, primitive-0.6.1.1, primitive-0.6.1.0,
primitive-0.5.4.0, primitive-0.5.3.0, primitive-0.5.2.1, primitive-0.5.1.0,
primitive-0.5.0.1, primitive-0.5, primitive-0.4.1, primitive-0.4.0.1,
primitive-0.4, primitive-0.3.1, primitive-0.3, primitive-0.2.1, primitive-0.2,
primitive-0.1, primitive-0.6.3.0, primitive-0.6.2.0, primitive-0.6.1.2,
primitive-0.6 (constraint from user target requires ==0.7.2.0)
[__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-0.6.4.0
Downloaded   primitive-0.6.4.0
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - primitive-0.6.4.0 (lib) (requires build)
Starting     primitive-0.6.4.0 (lib)
Building     primitive-0.6.4.0 (lib)

Failed to build primitive-0.6.4.0.
Build log (
/home/libo/.cabal/logs/ghc-8.10.7/primitive-0.6.4.0-48119d55912e202e94d46ddf34d3eee821e2cc6dae044da83bdf0c5b1582862c.log
):
Configuring library for primitive-0.6.4.0..
Preprocessing library for primitive-0.6.4.0..
Building library for primitive-0.6.4.0..
[ 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-0.6.4.0. 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
0.7.3.0 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-0.7.2.0 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