12

Whenever xmonad starts, restarts, or is recompiled, I get an xmessage:

xmonad.hs:1:8:
Could not find module `XMonad'
 Perhaps you meant
    Monad (needs flag -package haskell98-2.0.0.2)
    CgMonad (needs flag -package ghc-7.6.3)
    DsMonad (needs flag -package ghc-7.6.3)
 Use -v to see a list of the files searched for

This doesn't stop it from starting, but I only see updates to xmonad or xmobar settings on system reboot. My current xmonad.hs is just

import XMonad

main = xmonad defaultConfig

and it still produces the error. Any attempts to import other modules give similar results. I have both xmonad and xmonad-contrib installed from the Arch repositories, so the modules should be properly in the ghc search path, right? I've tried reinstalling the packages from Cabal like some other sources have suggested, but it turned into a complete snafu, so I went back to the Arch repos, which ought to work. Kind of at a loss for where to go from here; any help would be greatly appreciated.

EDIT: ghc-pkg list xmonad returns

/usr/lib/ghc-7.6.3/packag.conf.d
    xmonad-0.11
/home/decalis/.ghc/x86_64-linux-7.6.3/package.conf.d

and ghc-pkg check output is here: http://pastebin.com/BsCPMn8M. The issue is a little clearer after seeing that, but I still don't get why it's looking in ~/.cabal when all of the packages and their dependencies were resolved from the Arch repos by pacman.

Decalis
  • 123
  • 1
  • 1
  • 6
  • Please show the output of `ghc-pkg list xmonad` and `ghc-pkg check` – Roman Cheplyaka Mar 13 '14 at 21:35
  • Added to bottom of main question. – Decalis Mar 14 '14 at 16:25
  • No, that looks normal. Do you have any other ghc versions installed? Did you create any sandboxes? Try removing (or renaming) the `~/.cabal` and `~/.ghc` directories and see if that helps. Check whether you have any other `xmonad` binaries in your `$PATH`. – Roman Cheplyaka Mar 14 '14 at 16:32
  • Removing `~/.ghc` seems to have fixed all of the aberrant behavior. Restarting XMonad works smoothly, settings update appropriately, and `ghc-pkg check` now only complains about Haddock (which it always has). Thanks for the help! If you want to post that as an answer, I'll accept it. – Decalis Mar 14 '14 at 16:56
  • If only I knew *why* that fixed the problem! From the data you posted it doesn't look like your global xmonad was shadowed by the local one, or anything like that. Ok, I'll post some general advice about such problems. – Roman Cheplyaka Mar 14 '14 at 22:05

2 Answers2

8

For me the solution was to run ghc-pkg recache since the ghc cache was just out of sync for some reason. It's worth trying before wiping the whole ghc database.

André Laszlo
  • 15,169
  • 3
  • 63
  • 81
7

In cases like this one of the first things to try is to "start from scratch", i.e. forget about all the local packages that you might have installed in the past.

To do this, wipe (or rename/move) ghc's package database, which is under ~/.ghc/$arch-$os-$ghcver (such as ~/.ghc/i386-linux-7.6.3). Or just remove ~/.ghc altogether.

Roman Cheplyaka
  • 37,738
  • 7
  • 72
  • 121