ghc-mod and cabal "could not find module Prelude"

Hi I've recently set up a new Haskell working environment on Ubuntu 14.04. I installed the Ubuntu packaged version of Haskell platform. My problem is that I can't now get ghc-mod check to work if there is a cabal file in the current directory. I am using: * ghc-mod 5.2.1.2 compiled by GHC 7.6.3 * cabal 1.16.0.2 See below an extract of trying to run ghc-mod check in a directory that was empty until I just ran cabal init in it: ~/tmp-ghc-mod$ ls Setup.hs tmp-ghc-mod.cabal ~/tmp-ghc-mod$ ghc-mod check Setup.hs Setup.hs:1:1:Could not find module `Prelude'It is a member of the hidden package `base'.Perhaps you need to add `base' to the build-depends in your .cabal file.It is a member of the hidden package `haskell98-2.0.0.2'.Perhaps you need to add `haskell98' to the build-depends in your .cabal file.It is a member of the hidden package `haskell2010-1.1.1.0'.Perhaps you need to add `haskell2010' to the build-depends in your .cabal file.Use -v to see a list of the files searched for. ~/tmp-ghc-mod$ mv tmp-ghc-mod.cabal tmp-ghc-mod.cabal.NOT ~/tmp-ghc-mod$ ls dist Setup.hs tmp-ghc-mod.cabal.NOT ~/tmp-ghc-mod$ ghc-mod check Setup.hs Setup.hs:2:1:Warning: Top-level binding with no type signature: main :: IO () ~/tmp-ghc-mod$ So. ghc-mod behaves as expected when there is no cabal file, but doesn't behave as expected if there is a cabal file. My google fu isn't helping me out on this: the only issues I have seen are to do with a change in format of the cabal file in newer versions of cabal. Any ideas? Thanks Alan

Just add base as dependency in the version constraints matching that base
that is delivered with your version of GHC.
Alan Buxton
Hi
I’ve recently set up a new Haskell working environment on Ubuntu 14.04. I installed the Ubuntu packaged version of Haskell platform.
My problem is that I can’t now get ghc-mod check to work if there is a cabal file in the current directory.
I am using:
· ghc-mod 5.2.1.2 compiled by GHC 7.6.3
· cabal 1.16.0.2
See below an extract of trying to run ghc-mod check in a directory that was empty until I just ran cabal init in it:
~/tmp-ghc-mod$ ls
Setup.hs tmp-ghc-mod.cabal
~/tmp-ghc-mod$ ghc-mod check Setup.hs
Setup.hs:1:1:Could not find module `Prelude'It is a member of the hidden package `base'.Perhaps you need to add `base' to the build-depends in your .cabal file.It is a member of the hidden package `haskell98-2.0.0.2'.Perhaps you need to add `haskell98' to the build-depends in your .cabal file.It is a member of the hidden package `haskell2010-1.1.1.0'.Perhaps you need to add `haskell2010' to the build-depends in your .cabal file.Use -v to see a list of the files searched for.
~/tmp-ghc-mod$ mv tmp-ghc-mod.cabal tmp-ghc-mod.cabal.NOT
~/tmp-ghc-mod$ ls
dist Setup.hs tmp-ghc-mod.cabal.NOT
~/tmp-ghc-mod$ ghc-mod check Setup.hs
Setup.hs:2:1:Warning: Top-level binding with no type signature: main :: IO ()
~/tmp-ghc-mod$
So… ghc-mod behaves as expected when there is no cabal file, but doesn’t behave as expected if there is a cabal file.
My google fu isn’t helping me out on this: the only issues I have seen are to do with a change in format of the cabal file in newer versions of cabal.
Any ideas?
Thanks
Alan
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

Thanks for the suggestions:
Imants:
There is
library
build-depends: base ==4.6.*
(The cabal file was generated by cabal init and so I would hope it's legit :))
I installed Haskell on my Ubuntu just by doing sudo apt-get install haskell-platform.
Interestingly, if I do use ghc-mod on a real file with some errors in I get unnecessarily verbose error messages similar to described here: http://mail.haskell.org/pipermail/beginners/2015-February/014573.html I wonder if the issues are related somehow?
Norbert:
I’m not sure what exactly you are suggesting but if I even take the version constraint out of the cabal file so I have build-depends: base (without any version specified) then I get the same issue.
From: Beginners [mailto:beginners-bounces@haskell.org] On Behalf Of Norbert Melzer
Sent: 23 June 2015 17:49
To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell
Subject: Re: [Haskell-beginners] ghc-mod and cabal "could not find module Prelude"
Just add base as dependency in the version constraints matching that base that is delivered with your version of GHC.
Alan Buxton

Hi all
Thanks for the help you gave me on and off list. I wanted to let you know the solution in the end. The issue rested on the old version of cabal that I had (1.16). I had to install a newer version of cabal, but not 1.22, so using:
cabal install cabal-install --constraint "Cabal <1.22"
The gotcha here is that I had to then adjust my path so that the local ~/.cabal/bin directory comes first in the $PATH to ensure my local cabal was being used.
All the best
Alan
From: Alan Buxton [mailto:alanbuxton@gmail.com]
Sent: 23 June 2015 18:47
To: 'The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell'
Subject: RE: [Haskell-beginners] ghc-mod and cabal "could not find module Prelude"
Thanks for the suggestions:
Imants:
There is
library
build-depends: base ==4.6.*
(The cabal file was generated by cabal init and so I would hope it's legit :))
I installed Haskell on my Ubuntu just by doing sudo apt-get install haskell-platform.
Interestingly, if I do use ghc-mod on a real file with some errors in I get unnecessarily verbose error messages similar to described here: http://mail.haskell.org/pipermail/beginners/2015-February/014573.html I wonder if the issues are related somehow?
Norbert:
I’m not sure what exactly you are suggesting but if I even take the version constraint out of the cabal file so I have build-depends: base (without any version specified) then I get the same issue.
From: Beginners [mailto:beginners-bounces@haskell.org] On Behalf Of Norbert Melzer
Sent: 23 June 2015 17:49
To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell
Subject: Re: [Haskell-beginners] ghc-mod and cabal "could not find module Prelude"
Just add base as dependency in the version constraints matching that base that is delivered with your version of GHC.
Alan Buxton
participants (2)
-
Alan Buxton
-
Norbert Melzer