"While building package haskell-gi-base-0.26.0 (scroll up to its section to see the error) using:"

Hi everyone. I was searching for some small but useful program to learn how Haskell functionalities are looks like in practice and learn something by modifying it. I found one of DistroTube tutorial: https://www.youtube.com/watch?v=ViW-bcNQ6Lc&t=1291s I’ve cloned project from link below video but when i try to stack build it, i’ve got:

haskell-gi-base  > configure
haskell-gi-base  > Configuring haskell-gi-base-0.26.0...
haskell-gi-base  > Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2: The pkg-config package 'gobject-2.0'
haskell-gi-base  > version >=2.42 is required but it could not be found.
haskell-gi-base  > 
resourcet        > configure                   
resourcet        > Configuring resourcet-1.2.5...
resourcet        > build                       
typed-process    > configure                   
resourcet        > Preprocessing library for resourcet-1.2.5..
resourcet        > Building library for resourcet-1.2.5..
resourcet        > [1 of 5] Compiling Data.Acquire.Internal
resourcet        >                             
resourcet        > /tmp/stack-11406d953574cafb/resourcet-1.2.5/Data/Acquire/Internal.hs:16:1: warning: [-Wunused-imports]
resourcet        >     The import of ‘Control.Applicative’ is redundant
resourcet        >       except perhaps to import instances from ‘Control.Applicative’
resourcet        >     To import instances alone, use: import Control.Applicative()
resourcet        >    |                        
resourcet        > 16 | import Control.Applicative (Applicative (..))
resourcet        >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
typed-process    > Configuring typed-process-0.2.8.0...
typed-process    > build                       
vector           > configure                   
typed-process    > Preprocessing library for typed-process-0.2.8.0..
typed-process    > Building library for typed-process-0.2.8.0..
typed-process    > [1 of 3] Compiling Paths_typed_process
resourcet        > [2 of 5] Compiling Control.Monad.Trans.Resource.Internal
vector           > Configuring vector-0.12.3.1...
typed-process    > [2 of 3] Compiling System.Process.Typed.Internal
typed-process    > [3 of 3] Compiling System.Process.Typed
vector           > build                       
vector           > Preprocessing library for vector-0.12.3.1..
vector           > Building library for vector-0.12.3.1..
resourcet        >                             
resourcet        > /tmp/stack-11406d953574cafb/resourcet-1.2.5/Control/Monad/Trans/Resource/Internal.hs:28:29: warning: [-Wunused-imports]
resourcet        >     The import of ‘Applicative’
resourcet        >     from module ‘Control.Applicative’ is redundant
resourcet        >    |                        
resourcet        > 28 | import Control.Applicative (Applicative (..), Alternative(..))
resourcet        >    |                             ^^^^^^^^^^^^^^^^
resourcet        >                             
resourcet        > /tmp/stack-11406d953574cafb/resourcet-1.2.5/Control/Monad/Trans/Resource/Internal.hs:44:1: warning: [-Wdeprecations]
resourcet        >     Module ‘Control.Monad.Trans.List’ is deprecated:
resourcet        >       This transformer is invalid on most monads
resourcet        >    |                        
resourcet        > 44 | import Control.Monad.Trans.List     ( ListT    )
resourcet        >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
resourcet        >                             
resourcet        > /tmp/stack-11406d953574cafb/resourcet-1.2.5/Control/Monad/Trans/Resource/Internal.hs:57:1: warning: [-Wunused-imports]
resourcet        >     The import of ‘Control.Monad.IO.Class’ is redundant
resourcet        >       except perhaps to import instances from ‘Control.Monad.IO.Class’
resourcet        >     To import instances alone, use: import Control.Monad.IO.Class()
resourcet        >    |                        
resourcet        > 57 | import Control.Monad.IO.Class (MonadIO (..))
resourcet        >    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
resourcet        >                             
resourcet        > /tmp/stack-11406d953574cafb/resourcet-1.2.5/Control/Monad/Trans/Resource/Internal.hs:67:1: warning: [-Wunused-imports]
resourcet        >     The import of ‘Data.Word’ is redundant
resourcet        >       except perhaps to import instances from ‘Data.Word’
resourcet        >     To import instances alone, use: import Data.Word()
resourcet        >    |                        
resourcet        > 67 | import Data.Word(Word) 
resourcet        >    | ^^^^^^^^^^^^^^^^^^^^^^ 
resourcet        >                             
resourcet        > /tmp/stack-11406d953574cafb/resourcet-1.2.5/Control/Monad/Trans/Resource/Internal.hs:273:46: warning: [-Wdeprecations]
resourcet        >     In the use of type constructor or class ‘ListT’
resourcet        >     (imported from Control.Monad.Trans.List):
resourcet        >     Deprecated: "This transformer is invalid on most monads"
resourcet        >     |                       
resourcet        > 273 | GO(ListT)             
resourcet        >     |                                              ^^^^^
vector           > [ 1 of 21] Compiling Data.Vector.Fusion.Util
vector           > [ 2 of 21] Compiling Data.Vector.Fusion.Bundle.Size
vector           > [ 3 of 21] Compiling Data.Vector.Generic.Mutable.Base
resourcet        > [3 of 5] Compiling Data.Acquire
vector           > [ 4 of 21] Compiling Data.Vector.Generic.Base
vector           >                             
vector           > /tmp/stack-11406d953574cafb/vector-0.12.3.1/Data/Vector/Generic/Base.hs:34:27: warning: [-Wstar-is-type]
vector           >     Using ‘*’ (or its Unicode variant) to mean ‘Data.Kind.Type’
vector           >     relies on the StarIsType extension, which will become
vector           >     deprecated in the future.
vector           >     Suggested fix: use ‘Type’ from ‘Data.Kind’ instead.
vector           >    |                        
vector           > 34 | type family Mutable (v :: * -> *) = (mv :: * -> * -> *) | mv -> v
vector           >    |                           ^
vector           >                             
vector           > /tmp/stack-11406d953574cafb/vector-0.12.3.1/Data/Vector/Generic/Base.hs:34:32: warning: [-Wstar-is-type]
vector           >     Using ‘*’ (or its Unicode variant) to mean ‘Data.Kind.Type’
vector           >     relies on the StarIsType extension, which will become
vector           >     deprecated in the future.
vector           >     Suggested fix: use ‘Type’ from ‘Data.Kind’ instead.
vector           >    |                        
vector           > 34 | type family Mutable (v :: * -> *) = (mv :: * -> * -> *) | mv -> v
vector           >    |                                ^
vector           >                             
vector           > /tmp/stack-11406d953574cafb/vector-0.12.3.1/Data/Vector/Generic/Base.hs:34:44: warning: [-Wstar-is-type]
vector           >     Using ‘*’ (or its Unicode variant) to mean ‘Data.Kind.Type’
vector           >     relies on the StarIsType extension, which will become
vector           >     deprecated in the future.
vector           >     Suggested fix: use ‘Type’ from ‘Data.Kind’ instead.
vector           >    |                        
vector           > 34 | type family Mutable (v :: * -> *) = (mv :: * -> * -> *) | mv -> v
vector           >    |                                            ^
vector           >                             
vector           > /tmp/stack-11406d953574cafb/vector-0.12.3.1/Data/Vector/Generic/Base.hs:34:49: warning: [-Wstar-is-type]
vector           >     Using ‘*’ (or its Unicode variant) to mean ‘Data.Kind.Type’
vector           >     relies on the StarIsType extension, which will become
vector           >     deprecated in the future.
vector           >     Suggested fix: use ‘Type’ from ‘Data.Kind’ instead.
vector           >    |                        
vector           > 34 | type family Mutable (v :: * -> *) = (mv :: * -> * -> *) | mv -> v
vector           >    |                                                 ^
vector           >                             
vector           > /tmp/stack-11406d953574cafb/vector-0.12.3.1/Data/Vector/Generic/Base.hs:34:54: warning: [-Wstar-is-type]
vector           >     Using ‘*’ (or its Unicode variant) to mean ‘Data.Kind.Type’
vector           >     relies on the StarIsType extension, which will become
vector           >     deprecated in the future.
vector           >     Suggested fix: use ‘Type’ from ‘Data.Kind’ instead.
vector           >    |                        
vector           > 34 | type family Mutable (v :: * -> *) = (mv :: * -> * -> *) | mv -> v
vector           >    |                                                      ^
resourcet        > [4 of 5] Compiling Control.Monad.Trans.Resource
vector           > [ 5 of 21] Compiling Data.Vector.Internal.Check
resourcet        > [5 of 5] Compiling UnliftIO.Resource
vector           > [ 6 of 21] Compiling Data.Vector.Fusion.Stream.Monadic
resourcet        > copy/register               
resourcet        > Installing library in /home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/lib/x86_64-linux-ghc-9.0.2/resourcet-1.2.5-JM6arp9bvRfL7tfcKLafoq
resourcet        > Registering library for resourcet-1.2.5..
typed-process    > copy/register               
typed-process    > Installing library in /home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/lib/x86_64-linux-ghc-9.0.2/typed-process-0.2.8.0-71TK4T7IOIw8oVSFtUO91J
typed-process    > Registering library for typed-process-0.2.8.0..
vector           > [ 7 of 21] Compiling Data.Vector.Fusion.Bundle.Monadic
vector           > [ 8 of 21] Compiling Data.Vector.Fusion.Bundle
vector           > [ 9 of 21] Compiling Data.Vector.Generic.Mutable
vector           > [10 of 21] Compiling Data.Vector.Generic.New
vector           > [11 of 21] Compiling Data.Vector.Generic
vector           > [12 of 21] Compiling Data.Vector.Mutable
vector           > [13 of 21] Compiling Data.Vector
vector           > [14 of 21] Compiling Data.Vector.Primitive.Mutable
vector           > [15 of 21] Compiling Data.Vector.Primitive
vector           > [16 of 21] Compiling Data.Vector.Storable.Internal
vector           > [17 of 21] Compiling Data.Vector.Storable.Mutable
vector           > [18 of 21] Compiling Data.Vector.Storable
vector           > [19 of 21] Compiling Data.Vector.Unboxed.Base
vector           > [20 of 21] Compiling Data.Vector.Unboxed
vector           > [21 of 21] Compiling Data.Vector.Unboxed.Mutable
vector           > copy/register
vector           > Installing library in /home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/lib/x86_64-linux-ghc-9.0.2/vector-0.12.3.1-BmSroY3QVtCAOh838mXZ9M
vector           > Registering library for vector-0.12.3.1..
Progress 4/27        

--  While building package haskell-gi-base-0.26.0 (scroll up to its section to see the error) using:
      /home/tomasz/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.4.1.0_ghc-9.0.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0 configure --with-ghc=/home/tomasz/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-9.0.2 --with-ghc-pkg=/home/tomasz/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --user --package-db=clear --package-db=global --package-db=/home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/pkgdb --libdir=/home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/lib --bindir=/home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/bin --datadir=/home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/share --libexecdir=/home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/libexec --sysconfdir=/home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/etc --docdir=/home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/doc/haskell-gi-base-0.26.0 --htmldir=/home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/doc/haskell-gi-base-0.26.0 --haddockdir=/home/tomasz/.stack/snapshots/x86_64-linux-tinfo6/1cdd603d8fc6be0e7f0647214149148f2e6c37c5d68a139558b9752a89b51ac4/9.0.2/doc/haskell-gi-base-0.26.0 --dependency=base=base-4.15.1.0 --dependency=bytestring=bytestring-0.10.12.1 --dependency=containers=containers-0.6.4.1 --dependency=text=text-1.2.5.0 --exact-configuration --ghc-option=-fhide-source-paths
    Process exited with code: ExitFailure 1

Does anyone know how to fix it?

The error you’re seeing is:

haskell-gi-base  > The pkg-config package 'gobject-2.0' version >=2.42 is required but it could not be found.

This is saying that the haskell-gi-base Haskell library needs the system package gobject-2.0 (the pkg-config package) to have a version greater than 2.42, but on your system it does not.

You can probably use the pkg-config CLI tool to figure out what version of gobject-2.0 you have on your system (assuming you have gobject-2.0 at all).

The immediate solution to your problem is to install the system package gobject-2.0 to a version greater than 2.42, or to downgrade the version of haskell-gi-base you’re using (with the expectation that you only have an older version of gobject-2.0 on your system, and an older version of haskell-gi-base is usable with an older versions of gobject-2.0).


Although if you’re just trying to play around with Haskell, I might recommend getting started with something other than haskell-gi / gi-gtk. It can be a little difficult to install all required system libraries at the correct versions, along with all the Haskell libraries as sufficient versions.

Also, while haskell-gi is really neat (and I make big use of it in one of my own projects), almost all the code is auto-generated. It doesn’t give a good idea of what programming Haskell is actually like.

(That said, if you really like the idea of playing around with Haskell and haskell-gi, I don’t necessarily want to discourage you! It is pretty neat!)


Looks like a similar question was asked a few days ago:

Jaror pointed me to this site:
https://github.com/haskell-gi/haskell-gi#installation.
It worked for me.

1 Like