Not sure if this will help you but I was receiving a similar error when trying to recompile xmonad on OS X:
$ xmonad --recompile
XMonad will use ghc to recompile, because "/Users/scifisamurai/.xmonad/build" does not exist.
Error detected while loading xmonad configuration file: /Users/scifisamurai/.xmonad/xmonad.hs
Loaded package environment from /Users/scifisamurai/.ghc/x86_64-darwin-8.6.5/environments/default
xmonad.hs:10:1: error:
Could not load module ‘XMonad’
It is a member of the hidden package ‘xmonad-0.15’.
You can run ‘:set -package xmonad’ to expose it.
(Note: this unloads all the modules in the current scope.)
Use -v to see a list of the files searched for.
|
10 | import XMonad
| ^^^^^^^^^^^^^
xmonad.hs:20:1: error:
Could not load module ‘XMonad.StackSet’
It is a member of the hidden package ‘xmonad-0.15’.
You can run ‘:set -package xmonad’ to expose it.
(Note: this unloads all the modules in the current scope.)
Use -v to see a list of the files searched for.
|
20 | import qualified XMonad.StackSet as W
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Please check the file for errors.
I am running cabal version 3.0.0 though. However, I'm also using new-install.
The fix for me was adding --lib to the install command as mentioned here (though they're just using cabal install rather than cabal new-install):
https://github.com/xmonad/xmonad/issues/199#issue-490757289
LIBRARY_PATH=/opt/X11/lib:$LIBRARY_PATH cabal new-install --lib xmonad xmonad-contrib
Then trying to recompile again:
$ xmonad --recompile
XMonad will use ghc to recompile, because "/Users/scifisamurai/.xmonad/build" does not exist.
XMonad recompilation process exited with success!
Hope that helps someone.
Side notes:
- I'm also not seeing xmonad or xmonad-contrib listed in the output of
ghc-pkg list. There is some useful information on that here: https://github.com/haskell/cabal/issues/6262#issuecomment-541124411 which explains why that's happening and to look for the library in the package.db which did work for me:
$ ghc-pkg list -f ~/.cabal/store/ghc-8.6.5/package.db|egrep 'X11|xmonad'
X11-1.9.1
xmonad-0.15
xmonad-contrib-0.16
- I'm setting LIBRARY_PATH in the above command since X11 failed to build on OS X when I tried to build xmonad initially a while ago and that was the fix as per: https://github.com/xmonad/X11/issues/24#issuecomment-47996753
It may not be needed anymore.
In my Arch Linux VM, I use pacman to install xmonad which doesn't have the above issues. If you're using Linux I would think there would be a similar way to install this using your package manager. That being said though cabal should work ...