It turns out it was enough to execute
cabal install --package-env=$HOME/.config/xmonad --lib base xmonad xmonad-contrib
but what I don't understand is the following:
- why did this work?
- Why updating GHC via GHCup "breaks" the modules?
- When I write "breaks", given the original question below, should I say "hides"?
- What is a hidden package?
- Is executing
cabal install --lib the-stuff-that-hls-claims-hidden
wrong? - What is the correct way of updating with GHCup? (As apparently just running
ghcup tui
and doing i and s on new stuff and u on old stuff leaves things in a bad state.)
I think they all boil down to the some point: my misunderstanding of GHCup and the Haskell ecosystem in general.
Orignal question
When I started using XMonad, I had a hard time just running it, the reason being that I had installed via pacman
like any other program, as I'm on ArchLinux, but I also had ghc
installed in my home, via ghcup
, and available via the PATH
. Eventually I asked on ArchLinux forum, and manage to fix the problem.
My choice, at that time, was to install xmonad
via cabal
(installed via ghcup
). The reason for my choice is that I like GHCup and I find ghcup tui
a very convenient way to have the most recent recommended version of HLS, the most recent version of Cabal, the most recent recommended and hls-powered version of GHC.
And I thought I had understood what the implications of using XMonad installed via cabal
was.
But apparently I'm wrong: I've just updated via GHCup 0.1.20.0 to GHC 9.4.8, Cabal 3.10.2.1, and HLS 2.5.0.0, ...
... and now I can't recompile XMonad, the error being along the lines of "I can't find a single thing!", as you can see:
Errors detected while compiling xmonad config: /home/enlico/.config/xmonad/xmonad.hs
$ ghc --make xmonad.hs -i -ilib -fforce-recomp -main-is main -v0 -outputdir /home/enlico/.cache/xmonad/build-x86_64-linux -o /home/enlico/.cache/xmonad/xmonad-x86_64-linux
xmonad.hs:2:1: error:
Could not find module ‘XMonad’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
2 | import XMonad
| ^^^^^^^^^^^^^
xmonad.hs:3:1: error:
Could not find module ‘XMonad.Hooks.DynamicLog’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
3 | import XMonad.Hooks.DynamicLog
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:4:1: error:
Could not find module ‘XMonad.Hooks.EwmhDesktops’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
4 | import XMonad.Hooks.EwmhDesktops
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:5:1: error:
Could not find module ‘XMonad.Hooks.StatusBar’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
5 | import XMonad.Hooks.StatusBar
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:6:1: error:
Could not find module ‘XMonad.Hooks.StatusBar.PP’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
6 | import XMonad.Hooks.StatusBar.PP
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:7:1: error:
Could not find module ‘XMonad.Layout.NoBorders’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
7 | import XMonad.Layout.NoBorders
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:8:1: error:
Could not find module ‘XMonad.Layout.Spacing’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
8 | import XMonad.Layout.Spacing
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:9:1: error:
Could not find module ‘XMonad.Util.EZConfig’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
9 | import XMonad.Util.EZConfig (additionalKeysP)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:10:1: error:
Could not find module ‘XMonad.Util.Loggers’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
10 | import XMonad.Util.Loggers
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:11:1: error:
Could not find module ‘XMonad.Util.Ungrab’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
11 | import XMonad.Util.Ungrab
| ^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:12:1: error:
Could not find module ‘XMonad.StackSet’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
12 | import qualified XMonad.StackSet as W
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The unsuccessful attempt to fix things was:
cabal install --overwrite-policy=always --package-env=$HOME/.config/xmonad xmonad xmonad-contrib
The error above is upon recompiling XMonad, but beware, I've re-tried rempiling in order to get the error to paste here in the question, so I'm not 100% sure the error was identical upon recompiling XMonad right after I run the cabal
command above.
Incidentally, I've got used to the fact that when I update stuff via GHCup than something goes wrong with some modules.
For instance, right now I've opened a haskell file I used for a hackerrank challenge or something, and I notice that one line is marked as erroneous by HLS:
import Flow ((|>))
Executing cabal install --lib flow
fixes that.
But upon reloading HLS, another line shows an error:
import qualified Data.Map.Strict as M
and the error, now that I read, is this:
Could not load module ‘Data.Map.Strict’
It is a member of the hidden package ‘containers-0.6.7’.
You can run ‘:set -package containers’ to expose it.
(Note: this unloads all the modules in the current scope.)
and executing cabal install --lib containers
fixes is, but was that the right step?
xmonad.hs
/xmobar.hs
? – Distefano