Stack: Failures, Errors, Frustrations

So, I am at the point, where I want to expand my skills and start working with libraries. And here is where I run into an unbreakable brick wall. I have started numerous Stack projects to follow along tutorials or build my own projects. Every time I get these Errors after following the exact steps on the Stack site, or what the tutorials say I should do.

1: Could not find module ‘Data.Gi.Base’ or ‘aeson’
It is not a module in the current program, or in any known package.not found

2: I edit the package.yaml file like that :

  • base >= 4.7 && < 5
  • gi-gtk == 3.0.*
  • gi-gtk-hs
  • haskell-gi-base

and get that output after stack build :
haskell-gi-base> version >=2.42 is required but it could not be found.
Progress 1/15

Process exited with code: ExitFailure 1

I really need some help.

1 Like

What does your stack.yaml look like? Did you check that all your dependencies are part of the (lts-*?) snapshot you’re using? Otherwise, you may need to add some extra-deps.

I also think that you elided some necessary information from the error messages.

EDIT: In particular, it’s unclear what the version >= 2.42 message is referring to.

Hi sjakobi,
thank you very much for even asking some questions and trying to help.
This is the version:

Me neither. I just followed this guy, did everything he did :
Building a GTK App With Haskell (In Under An Hour) - YouTube (look at 7:04 min)
When I do stack build I get several of these “ExitFailiure” things…

Now the question to your question. How do I know (can I find out) what extra deps are needed.
I always tell myself “If you want to feel stupid and useless, learn programming” :smiley:
Really appreciate your help

Hey, you posted a link to something that stack uses under the hood. :slight_smile: You shouldn’t need that file in your project directory.

What about your package’s specific stack.yaml? It’s literally called “stack.yaml” and usually gets initialized by stack init.

Hey chreekat,
I just copied and pasted that link from the “stack.yaml” file. It is under the
Url: "here is that link.
Cheers Leo

Note that the app that you’re trying to copy is using lts-19.7: stack.yaml · main · Derek Taylor / ByeBye · GitLab

lts-19.7 is a bit different from lts-19.8, but I doubt that this is where your problems are coming from.

Can you show us a bit more of the context of that version >= 2.42 error you pasted? What package is it referring to?

Just give me a minute or 5. Out of frustration I deleted it. But I will set it up quickly…

here is exactly what I am doing.
1: stack new byebye
2: cd byebye
3: stack setup
4: open package.yaml and add:

  • gi-gtk == 3.0.*
  • gi-gtk-hs
  • haskell-gi-base

5: safe
6: stack build.


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.
Progress 1/15

– While building package haskell-gi-base-0.26.0 (scroll up to its section to see the error) using:
/home/lennaet/.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- configure --with-ghc=/home/lennaet/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-9.0.2 --with-ghc-pkg=/home/lennaet/.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/lennaet/.stack/snapshots/x86_64-linux-tinfo6/bf2b22f4a5ae48506d221d81a63a06f9c3cb87d893cb0fd275e19148a620237e/9.0.2/pkgdb --libdir=/home/lennaet/.stack/snapshots/x86_64-linux-tinfo6/bf2b22f4a5ae48506d221d81a63a06f9c3cb87d893cb0fd275e19148a620237e/9.0.2/lib --bindir=/home/lennaet/.stack/snapshots/x86_64-linux-tinfo6/bf2b22f4a5ae48506d221d81a63a06f9c3cb87d893cb0fd275e19148a620237e/9.0.2/bin --datadir=/home/lennaet/.stack/snapshots/x86_64-linux-tinfo6/bf2b22f4a5ae48506d221d81a63a06f9c3cb87d893cb0fd275e19148a620237e/9.0.2/share --libexecdir=/home/lennaet/.stack/snapshots/x86_64-linux-tinfo6/bf2b22f4a5ae48506d221d81a63a06f9c3cb87d893cb0fd275e19148a620237e/9.0.2/libexec --sysconfdir=/home/lennaet/.stack/snapshots/x86_64-linux-tinfo6/bf2b22f4a5ae48506d221d81a63a06f9c3cb87d893cb0fd275e19148a620237e/9.0.2/etc --docdir=/home/lennaet/.stack/snapshots/x86_64-linux-tinfo6/bf2b22f4a5ae48506d221d81a63a06f9c3cb87d893cb0fd275e19148a620237e/9.0.2/doc/haskell-gi-base-0.26.0 --htmldir=/home/lennaet/.stack/snapshots/x86_64-linux-tinfo6/bf2b22f4a5ae48506d221d81a63a06f9c3cb87d893cb0fd275e19148a620237e/9.0.2/doc/haskell-gi-base-0.26.0 --haddockdir=/home/lennaet/.stack/snapshots/x86_64-linux-tinfo6/bf2b22f4a5ae48506d221d81a63a06f9c3cb87d893cb0fd275e19148a620237e/9.0.2/doc/haskell-gi-base-0.26.0 --dependency=base=base- --dependency=bytestring=bytestring- --dependency=containers=containers- --dependency=text=text- --exact-configuration --ghc-option=-fhide-source-paths
Process exited with code: ExitFailure 1

1 Like

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.

This pkg-config package bit is referring to a system dependency which you need to install via your package manager. stack can only handle Haskell library dependencies.

On Ubuntu, I can use apt-file find to find the package that provides a certain system library:

$ apt-file find /gobject.h
guile-gnome2-dev: /usr/include/guile-gnome-2/guile-gnome-gobject/gobject.h
libglib2.0-dev: /usr/include/glib-2.0/gobject/gobject.h
r-cran-rgtk2: /usr/lib/R/site-library/RGtk2/include/RGtk2/gobject.h

So I would need to install libglib2.0-dev to fix this. On your system, the exact commands and package names might be a bit different.

1 Like

Also check the installation instructions of haskell-gi.

1 Like

Well, I am using Ubuntu as well but…Command ‘apt-file’ not found.

Apparently I have no idea what I am doing. I thought stack is the package manager…do I need another one?!? Why cant it be as straight forward as in Elm…buuaaaaahhhh :confounded:

…is Elm written in Elm?

apt-file is an administrative command. As I dimly recall, you’ll need to prefix those with sudo in Ubuntu (or log in to your system as an admin and then run it).

Hey jaror,
just followed the instructions and
now it seems to be doing what its supposed to do…How do you know these things?

1 Like

Elm is written is Haskell…as far as I know. But I am not Mr. knowitall…as it is apparent :joy:

I’ve encountered similar issues before when trying to use GTK or other C libraries in Haskell. It basically comes down to having spent too much more time on it.

1 Like

Never in a million years would I have solved this issue by myself. Thanks to all of you!!!
But there is still this other issue.

now when I do the imports

import Data.GI.Base
import qualified GI.Gtk

why do I get these messages:

Could not find module ‘Data.GI.Base’
It is not a module in the current program, or in any known package

Have the same with aeson, random etc. But the program compiles…

The “Could not find module …” error message usually means that you are missing a dependency in your package.yaml file.

The Data.GI.Base is a bit confusing because I believe you say that you have haskell-gi-base listed in your package.yaml. That should be enough. Maybe you should check it again? Also note that there might be multiple dependencies: fields in one package.yaml file.

For the others like aeson and random it seems you are just missing the dependency in your package.yaml.

There are some more pointers about adding dependencies in the Stack documentation.

Ok, homework for me. Read the complete Stack documentation…
Well, I list all these dependencies like so

dependencies :

safe the file do stack build and still get the same errors…

Can you post the full package.yaml file that you are using? Preferably via or something like that.

I dont have an account for pastebin yet. So here is the entire file content.

name:                hauth
github:              "githubuser/hauth"
license:             BSD3
author:              "Author name here"
maintainer:          ""
copyright:           "2022 Author name here"


# Metadata used when publishing your package
# synopsis:            Short description of your package
# category:            Web

# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the file.
description:         Please see the README on GitHub at <>

- base
- classy-prelude
- time
- aeson
- random

- NoImplicitPrelude 
- OverloadedStrings
- QuasiQuotes

  source-dirs: src

    main:                Main.hs
    source-dirs:         app
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    - hauth

    main:                Spec.hs
    source-dirs:         test
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    - hauth