Toy GUI project

I’m trying to build a little toy GUI app depending on gi-gtk. I’m on Fedora 39. AFAICT I have all the required dependencies installed but I can’t get it to compile. I always get

cabal build
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: gtk-intro-0.1.0.0 (user goal)
[__1] next goal: gi-gtk (dependency of gtk-intro)
[__1] rejecting: gi-gtk-4.0.8, gi-gtk-4.0.6, gi-gtk-4.0.5, gi-gtk-4.0.4,
gi-gtk-4.0.3, gi-gtk-4.0.2, gi-gtk-4.0.1 (conflict: pkg-config package
gtk4-any, not found in the pkg-config database)
[__1] rejecting: gi-gtk-3.0.41, gi-gtk-3.0.39, gi-gtk-3.0.38, gi-gtk-3.0.37,
gi-gtk-3.0.36, gi-gtk-3.0.35, gi-gtk-3.0.34, gi-gtk-3.0.33, gi-gtk-3.0.32,
gi-gtk-3.0.31, gi-gtk-3.0.30, gi-gtk-3.0.29, gi-gtk-3.0.28, gi-gtk-3.0.27,
gi-gtk-3.0.26, gi-gtk-3.0.25, gi-gtk-3.0.24, gi-gtk-3.0.23, gi-gtk-3.0.22,
gi-gtk-3.0.21, gi-gtk-3.0.20, gi-gtk-3.0.19, gi-gtk-3.0.18, gi-gtk-3.0.17,
gi-gtk-3.0.16, gi-gtk-3.0.15, gi-gtk-3.0.14, gi-gtk-3.0.13, gi-gtk-3.0.12,
gi-gtk-3.0.11, gi-gtk-3.0.10, gi-gtk-3.0.9, gi-gtk-3.0.8, gi-gtk-3.0.7,
gi-gtk-3.0.6, gi-gtk-3.0.5, gi-gtk-3.0.4, gi-gtk-3.0.3, gi-gtk-3.0.2,
gi-gtk-3.0.1 (conflict: pkg-config package gtk+-3.0-any, not found in the
pkg-config database)
[__1] rejecting: gi-gtk-0.3.18.15, gi-gtk-0.3.18.14, gi-gtk-0.3.18.13,
gi-gtk-0.3.18.12 (conflict: pkg-config package gtk+-3.0>=3.18, not found in
the pkg-config database)
[__1] rejecting: gi-gtk-0.3.16.12 (conflict: pkg-config package
gtk+-3.0>=3.16, not found in the pkg-config database)
[__1] rejecting: gi-gtk-0.3.18.10 (conflict: pkg-config package
gtk+-3.0>=3.18, not found in the pkg-config database)
[__1] rejecting: gi-gtk-0.3.16.11, gi-gtk-0.3.16.10, gi-gtk-0.3.16.9,
gi-gtk-0.3.16.8 (conflict: pkg-config package gtk+-3.0>=3.16, not found in the
pkg-config database)
[__1] fail (backjumping, conflict set: gi-gtk, gtk-intro)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: gi-gtk, base, gtk-intro

pkg-config seems to indicate that I have those dependencies installed:

pkg-config --list-all | grep gtk
javascriptcoregtk-4.0          JavaScriptCoreGTK+ - GTK+ version of the JavaScriptCore engine
gtk+-3.0                       GTK+ - GTK+ Graphical UI Library
gtk+-broadway-3.0              GTK+ - GTK+ Graphical UI Library
gtk+-unix-print-3.0            GTK+ - GTK+ Unix print support
gtk+-wayland-3.0               GTK+ - GTK+ Graphical UI Library
gtk+-x11-3.0                   GTK+ - GTK+ Graphical UI Library
gtksourceview-3.0              gtksourceview - Source code editing widget
webkit2gtk-4.0                 WebKitGTK - Web content engine for GTK
webkit2gtk-web-extension-4.0   WebKitGTK web process extensions - Web content engine for GTK - web process extensions
gtk+                           GTK+ - GIMP Tool Kit
gtk4-broadway                  GTK - GTK Graphical UI Library
gtk4-unix-print                GTK - GTK Unix print support
gtk4-wayland                   GTK - GTK Graphical UI Library
gtk4-x11                       GTK - GTK Graphical UI Library
gtk4                           GTK - GTK Graphical UI Library

Any suggestions?

1 Like

The haskell-gi readme lists this as the required dependencies:

sudo dnf install gobject-introspection-devel webkitgtk4-devel gtksourceview3-devel

Maybe you’re missing the -devel versions?

1 Like

Yes, I’ve done that already (and I double checked, again). They’re all installed.

What does this say? Is the result >= 3.18?

pkg-config --modversion gtk+-3.0 

(That wouldn’t explain why it can’t satisfy gtk+-3.0-any, but I think it would be interesting to know anyway.)

It says:

pkg-config --modversion gtk+-3.0 
3.24.41
1 Like

This sounds rather like Cabal 3.10.2.1 cannot parse `pkg-config`: `hGetContents: invalid argument (invalid byte sequence)` · Issue #9608 · haskell/cabal · GitHub . If that’s actually the problem, updating libvpl in your system should solve it, as the upstream fix in libvpl 2.10.2 has landed in Fedora a couple weeks ago.

I don’t have libvpl on my system so the non-unicode character issue afflicting Cabal doesn’t seem likely.

Looking through that ticket, I see I can make Cabal more verbose. It outputs:

...
Resolving dependencies...                                                       
CallStack (from HasCallStack):                                                  
  withMetadata, called at src/Distribution/Simple/Utils.hs:368:14 in Cabal-3.10.2.1-inplace:Distribution.Simple.Utils
Error: cabal: Could not resolve dependencies:                             
[__0] trying: gtk-intro-0.1.0.0 (user goal)                                                                                                                     
[__1] next goal: gi-gtk (dependency of gtk-intro)                                                                                                               
[__1] rejecting: gi-gtk-4.0.8, gi-gtk-4.0.6, gi-gtk-4.0.5, gi-gtk-4.0.4,
gi-gtk-4.0.3, gi-gtk-4.0.2, gi-gtk-4.0.1 (conflict: pkg-config package   
gtk4-any, not found in the pkg-config database)     
[__1] rejecting: gi-gtk-3.0.41, gi-gtk-3.0.39, gi-gtk-3.0.38, gi-gtk-3.0.37,
gi-gtk-3.0.36, gi-gtk-3.0.35, gi-gtk-3.0.34, gi-gtk-3.0.33, gi-gtk-3.0.32, 
gi-gtk-3.0.31, gi-gtk-3.0.30, gi-gtk-3.0.29, gi-gtk-3.0.28, gi-gtk-3.0.27,
gi-gtk-3.0.26, gi-gtk-3.0.25, gi-gtk-3.0.24, gi-gtk-3.0.23, gi-gtk-3.0.22,
gi-gtk-3.0.21, gi-gtk-3.0.20, gi-gtk-3.0.19, gi-gtk-3.0.18, gi-gtk-3.0.17,      
gi-gtk-3.0.16, gi-gtk-3.0.15, gi-gtk-3.0.14, gi-gtk-3.0.13, gi-gtk-3.0.12,      
gi-gtk-3.0.11, gi-gtk-3.0.10, gi-gtk-3.0.9, gi-gtk-3.0.8, gi-gtk-3.0.7,                                                                                         
gi-gtk-3.0.6, gi-gtk-3.0.5, gi-gtk-3.0.4, gi-gtk-3.0.3, gi-gtk-3.0.2,                                                                                           
gi-gtk-3.0.1 (conflict: pkg-config package gtk+-3.0-any, not found in the                                                                                       
pkg-config database)                                                                                                                                            
[__1] rejecting: gi-gtk-0.3.18.15, gi-gtk-0.3.18.14, gi-gtk-0.3.18.13,                                                                                          
gi-gtk-0.3.18.12 (conflict: pkg-config package gtk+-3.0>=3.18, not found in                                                                                     
the pkg-config database)                                                                                                                                        
[__1] rejecting: gi-gtk-0.3.16.12 (conflict: pkg-config package                                                                                                 
gtk+-3.0>=3.16, not found in the pkg-config database)                                                                                                           
[__1] rejecting: gi-gtk-0.3.18.10 (conflict: pkg-config package                                                                                                 
gtk+-3.0>=3.18, not found in the pkg-config database)                                                                                                           
[__1] rejecting: gi-gtk-0.3.16.11, gi-gtk-0.3.16.10, gi-gtk-0.3.16.9,                                                                                           
gi-gtk-0.3.16.8 (conflict: pkg-config package gtk+-3.0>=3.16, not found in the                                                                                  
pkg-config database)                                                                                                                                            
[__1] fail (backjumping, conflict set: gi-gtk, gtk-intro)                                                                                                       
After searching the rest of the dependency tree exhaustively, these were the                                                                                    
goals I've had most trouble fulfilling: gi-gtk (58), gtk-intro (2)                              
...

BTW I’m using

cabal --version
cabal-install version 3.10.2.1
compiled using version 3.10.2.1 of the Cabal library 
1 Like

Does anything mentioned here help?

I traced (using strace) what Cabal is doing behind the scenes and I see that Cabal executes:

/usr/bin/x86_64-redhat-linux-gnu-pkg-config --modversion libfolly fmt rocksdb fwupd-efi grilo-plugins-0.3 libcrypt libxcrypt gmp gmpxx libzstd zlib bzip2 xau pthread-stubs xcb-composite xcb-damage xcb-dpms xcb-dri2 xcb-dri3 xcb-glx xcb-present xcb-randr xcb-record xcb-render xcb-res xcb-screensaver xcb-shape xcb-shm xcb-sync xcb-xf86dri xcb-xfixes xcb-xinerama xcb-xinput xcb-xkb xcb-xselinux xcb-xtest xcb-xv xcb-xvmc xcb libglvnd egl gl glesv1_cm glesv2 glx opengl glu glew pciaccess xext xrender xfixes xcursor xi xinerama glfw3 x11-xcb x11 xrandr gflags icu-i18n icu-io icu-uc libpcre libpcre16 libpcre32 libpcrecpp libpcreposix libglog libxxhash snappy libcrypto libssl openssl liblz4 libunwind-coredump libunwind-generic libunwind-ptrace libunwind libevent libevent_core libevent_extra libevent_openssl libevent_pthreads sqlite3 wayland-eglstream tcl libpcre2-16 libpcre2-32 libpcre2-8 libpcre2-posix sysprof-capture-4 liblzma libxml-2.0 libsepol libselinux libpng libpng16 libffi graphite2 libbrotlicommon libbrotlidec libbrotlienc harfbuzz-cairo harfbuzz-gobject harfbuzz-icu harfbuzz-subset harfbuzz freetype2 xft tk libsodium gio-2.0 gio-unix-2.0 glib-2.0 gmodule-2.0 gmodule-export-2.0 gmodule-no-export-2.0 gobject-2.0 gthread-2.0 sdl2 sdl12_compat SDL_ttf gtest gtest_main gmock gmock_main fmt python-2.7 python2 libdrm libdrm_amdgpu libdrm_intel libdrm_nouveau libdrm_radeon fftw3 fftw3f fftw3l fftw3q alsa-topology alsa fontconfig expat dri blkid mount form formw menu menuw ncurses++ ncurses++w ncurses ncursesw panel panelw tic tinfo z3 libsystemd libudev pixman-1 cairo-fc cairo-ft cairo-pdf cairo-png cairo-ps cairo-script-interpreter cairo-script cairo-svg cairo-tee cairo-xcb-shm cairo-xcb cairo-xlib-xrender cairo-xlib cairo cairo-gobject atk fribidi dbus-1 javascriptcoregtk-4.0 libpsl libsoup-2.4 libsoup-gnome-2.4 xkbcommon xkbregistry cloudproviders wayland-client wayland-cursor wayland-egl-backend wayland-egl wayland-scanner wayland-server libtiff-4 libjpeg gdk-pixbuf-2.0 epoxy datrie-0.2 libthai pango pangocairo pangofc pangoft2 pangoot pangoxft xtst atspi-2 atk-bridge-2.0 xdamage xcomposite gail-3.0 gdk-3.0 gdk-broadway-3.0 gdk-wayland-3.0 gdk-x11-3.0 gtk+-3.0 gtk+-broadway-3.0 gtk+-unix-print-3.0 gtk+-wayland-3.0 gtk+-x11-3.0 gtksourceview-3.0 webkit2gtk-4.0 webkit2gtk-web-extension-4.0 gobject-introspection-1.0 gobject-introspection-no-export-1.0 ice glib gmodule gthread sm xt gdk gtk+ graphene-1.0 graphene-gobject-1.0 gtk4-broadway gtk4-unix-print gtk4-wayland gtk4-x11 gtk4 plasma-key-data bash-completion gnome-video-effects shared-mime-info bigreqsproto compositeproto damageproto dmxproto dpmsproto dri2proto dri3proto fixesproto fontsproto glproto inputproto kbproto presentproto randrproto recordproto renderproto resourceproto scrnsaverproto videoproto xcmiscproto xextproto xf86bigfontproto xf86dgaproto xf86driproto xf86vidmodeproto xineramaproto xproto xwaylandproto eglexternalplatform wayland-eglstream-protocols dracut emacs wayland-protocols systemd udev gnome-keybindings

I then ran this directly on a command line and it prints a single version

0.58.0-dev 

The command line seems to “hope” that this single invocation of pkg-config would yield all the versions of this multitude of packages but it clearly doesn’t.

1 Like

What happens if shorter argument lists are given? For example:

  1. ...pkg-config --modversion libfolly fmt rocksdb

  2. ...pkg-config --modversion libfolly fmt

  3. ...pkg-config --modversion libfolly

  4. ...pkg-config --modversion

pkg-config --modversion libfolly fmt
0.58.0-dev
pkg-config --modversion libfolly 
0.58.0-dev
pkg-config --modversion fmt
9.1.0
pkg-config --modversion 
Please specify at least one package name on the command line.

So pkg-config --modversion alone only provides the current version of the first given package argument and ignores the rest - that suggests an extra command-line option is needed to tell pkg-config to do that for all the remaining arguments. To find out what other options your version of pkg-config supports, you can try either --help or -? (or something similar).

I’ve compiled the HEAD of the Cabal repo and I can compile my toy program with that (unreleased) version. I suspect that this commit fixed the issue.

3 Likes