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 :
dependencies:
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.
haskell-gi-base>
Progress 1/15
…
Process exited with code: ExitFailure 1
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.
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”
Really appreciate your help
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.
output:
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>
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-3.4.1.0 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-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
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:
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
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).
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.
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.
I dont have an account for pastebin yet. So here is the entire file content.
name: hauth
version: 0.1.0.0
github: "githubuser/hauth"
license: BSD3
author: "Author name here"
maintainer: "example@example.com"
copyright: "2022 Author name here"
extra-source-files:
- README.md
- ChangeLog.md
# 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 README.md file.
description: Please see the README on GitHub at <https://github.com/githubuser/hauth#readme>
dependencies:
- base
- classy-prelude
- time
- aeson
- random
default-extensions:
- NoImplicitPrelude
- OverloadedStrings
- QuasiQuotes
library:
source-dirs: src
executables:
hauth-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- hauth
tests:
hauth-test:
main: Spec.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- hauth