
Hi, It seems I've been able to mess up my ghc installation pretty badly. Here is what happens if I just try to invoke ghci from the prompt: $ ghci GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. <command line>: module `Prelude' is not loaded $ I have no idea what I did to end up in this situation. What I've been doing lately is reinstalling some packages. I also have another ghc installed but it's at a completely different place in the file system. The only thing I can think of is if cabal managed to somehow confuse the two ghcs and wrote some data in the wrong place. What I really would like to know is if there is a simple way to fix this without completely reinstalling ghc with all the libraries I have installed. Has anyone else experienced anything similar? If this is a potential bug I'd be happy to provide any data that might help track it down. Cheers, Josef

On Mon, Mar 1, 2010 at 11:43 AM, Josef Svenningsson
What I really would like to know is if there is a simple way to fix this without completely reinstalling ghc with all the libraries I have installed. Has anyone else experienced anything similar?
Here's what I'd do, with the caveat that I'm still a Haskell novice: 1) Check your ~/.ghci file and make sure it's not doing anything strange. (You may not have one, which is fine.) 2) If rebuilding your cabal-installed libs and reinstalling cabal is fine, delete your ~/.ghc and ~/.cabal directories, make sure ghci works, and then re-install cabal and go from there.

is there, by chance, a file named Prelude.hs in the working directory? (the directory you are in when you type ghci?) - jeremy On Mon, Mar 1, 2010 at 11:43 AM, Josef Svenningsson < josef.svenningsson@gmail.com> wrote:
Hi,
It seems I've been able to mess up my ghc installation pretty badly. Here is what happens if I just try to invoke ghci from the prompt:
$ ghci GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. <command line>: module `Prelude' is not loaded $
I have no idea what I did to end up in this situation. What I've been doing lately is reinstalling some packages. I also have another ghc installed but it's at a completely different place in the file system. The only thing I can think of is if cabal managed to somehow confuse the two ghcs and wrote some data in the wrong place.
What I really would like to know is if there is a simple way to fix this without completely reinstalling ghc with all the libraries I have installed. Has anyone else experienced anything similar?
If this is a potential bug I'd be happy to provide any data that might help track it down.
Cheers,
Josef _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

On Mon, Mar 1, 2010 at 11:54 PM, Jeremy Shaw
is there, by chance, a file named Prelude.hs in the working directory? (the directory you are in when you type ghci?) - jeremy
Ah. Thanks! That was indeed the problem. Though I think ghci:s response could be a little bit more transparent. Josef
On Mon, Mar 1, 2010 at 11:43 AM, Josef Svenningsson
wrote: Hi,
It seems I've been able to mess up my ghc installation pretty badly. Here is what happens if I just try to invoke ghci from the prompt:
$ ghci GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. <command line>: module `Prelude' is not loaded $
I have no idea what I did to end up in this situation. What I've been doing lately is reinstalling some packages. I also have another ghc installed but it's at a completely different place in the file system. The only thing I can think of is if cabal managed to somehow confuse the two ghcs and wrote some data in the wrong place.
What I really would like to know is if there is a simple way to fix this without completely reinstalling ghc with all the libraries I have installed. Has anyone else experienced anything similar?
If this is a potential bug I'd be happy to provide any data that might help track it down.
Cheers,
Josef _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

On 02/03/2010 08:59, Josef Svenningsson wrote:
On Mon, Mar 1, 2010 at 11:54 PM, Jeremy Shaw
wrote: is there, by chance, a file named Prelude.hs in the working directory? (the directory you are in when you type ghci?) - jeremy
Ah. Thanks! That was indeed the problem.
Though I think ghci:s response could be a little bit more transparent.
Sure, how about this: $ touch Prelude.hs $ ghci GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package ffi-1.0 ... linking ... done. Prelude> ie. with 6.12.1 it just works. Cheers, Simon

On Tue, Mar 2, 2010 at 12:21 PM, Simon Marlow
On 02/03/2010 08:59, Josef Svenningsson wrote:
On Mon, Mar 1, 2010 at 11:54 PM, Jeremy Shaw
wrote: is there, by chance, a file named Prelude.hs in the working directory? (the directory you are in when you type ghci?) - jeremy
Ah. Thanks! That was indeed the problem.
Though I think ghci:s response could be a little bit more transparent.
Sure, how about this:
$ touch Prelude.hs $ ghci GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package ffi-1.0 ... linking ... done. Prelude>
ie. with 6.12.1 it just works.
Brilliant! Thanks. Josef

I would still vote for that error in the 'worst ghc error message contest'.
I got it just last night with 6.13 when I tried to run the Setup.hs function
in base:
~/n-heptane/projects/haskell/darcs/base-3.0.3.2 $ rm Setup.o Setup.hi
~/n-heptane/projects/haskell/darcs/base-3.0.3.2 $ ghc --make -O2 Setup.hs -o
s
[1 of 1] Compiling Main ( Setup.hs, Setup.o )
Setup.hs:1:1:
attempting to use module `Prelude' (./Prelude.hs) which is not loaded
~/n-heptane/projects/haskell/darcs/base-3.0.3.2 $ runhaskell Setup.hs
configure
Setup.hs:1:1:
attempting to use module `Prelude' (./Prelude.hs) which is not loaded
~/n-heptane/projects/haskell/darcs/base-3.0.3.2 $
In this case it does at least mention the path to the troublesome file. But
I still have no idea why it is not loaded** (In this particular case I don't
want it loaded. Though I believe there are other similar situations where I
do..)
** well, from experience I know that it is 'not loaded' because it can't
decide if it should load the source, or use the version installed in the
package library. But the first time I saw the message, I was quite confused.
But, perhaps there are other cases when this error can occur?
- jeremy
On Tue, Mar 2, 2010 at 5:21 AM, Simon Marlow
On 02/03/2010 08:59, Josef Svenningsson wrote:
On Mon, Mar 1, 2010 at 11:54 PM, Jeremy Shaw
wrote: is there, by chance, a file named Prelude.hs in the working directory? (the directory you are in when you type ghci?) - jeremy
Ah. Thanks! That was indeed the problem.
Though I think ghci:s response could be a little bit more transparent.
Sure, how about this:
$ touch Prelude.hs $ ghci GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done. Loading package ffi-1.0 ... linking ... done. Prelude>
ie. with 6.12.1 it just works.
Cheers, Simon

On 02/03/2010 15:46, Jeremy Shaw wrote:
I would still vote for that error in the 'worst ghc error message contest'. I got it just last night with 6.13 when I tried to run the Setup.hs function in base:
~/n-heptane/projects/haskell/darcs/base-3.0.3.2 $ rm Setup.o Setup.hi ~/n-heptane/projects/haskell/darcs/base-3.0.3.2 $ ghc --make -O2 Setup.hs -o s [1 of 1] Compiling Main ( Setup.hs, Setup.o )
Setup.hs:1:1: attempting to use module `Prelude' (./Prelude.hs) which is not loaded ~/n-heptane/projects/haskell/darcs/base-3.0.3.2 $ runhaskell Setup.hs configure
Setup.hs:1:1: attempting to use module `Prelude' (./Prelude.hs) which is not loaded ~/n-heptane/projects/haskell/darcs/base-3.0.3.2 $
Oh, the problem here is that GHC hasn't figured out that it should consider Prelude to be a local dependency of Setup, because it only looks at the imports, and Prelude is an implicit import. With Prelude not being found during dependency analysis, it wasn't compiled first, so when we got around to trying to import it we found that it was not "loaded". Perhaps the implicit import of Prelude should be import "base" Prelude rather than import Prelude that would avoid these problems. But it would present a problem for someone who wanted to use their own Prelude. At the least I guess we should consider Prelude to be an implicit dependency during dependency analysis. What you wanted to do above was "ghc --make Setup -i", incedentally. And if we fix the dependency thing, you'll still need to do that, because otherwise GHC will try to recompile the whole of base, and something else will almost certainly go wrong because there will be two Preludes. Cheers, Simon

Jeremy Shaw wrote:
I would still vote for that error in the 'worst ghc error message contest'...
Simon Marlow wrote:
Oh, the problem here is that... when we got around to trying to import it we found that it was not "loaded". Perhaps the implicit import of Prelude should be... What you wanted to do above was "ghc --make Setup -i"... And if we fix the dependency thing, you'll still need to do that, because otherwise...
Simon, Thank you for your incessant focus on making GHC excellent in every case! Even so, Prelude does seem to be a special case here, and in that special case the error message really is bad. It even confused Josef. Can't we add something like "(Is there more than one Prelude in your path?)" to the message for Prelude? Just in case somehow, somewhere, this does happen to someone again? Thanks, Yitz

On 02/03/2010 17:45, Yitzchak Gale wrote:
Jeremy Shaw wrote:
I would still vote for that error in the 'worst ghc error message contest'...
Simon Marlow wrote:
Oh, the problem here is that... when we got around to trying to import it we found that it was not "loaded". Perhaps the implicit import of Prelude should be... What you wanted to do above was "ghc --make Setup -i"... And if we fix the dependency thing, you'll still need to do that, because otherwise...
Simon,
Thank you for your incessant focus on making GHC excellent in every case!
Even so, Prelude does seem to be a special case here, and in that special case the error message really is bad. It even confused Josef.
Can't we add something like "(Is there more than one Prelude in your path?)" to the message for Prelude? Just in case somehow, somewhere, this does happen to someone again?
After making the fix I mentioned previously, the result is now this: libraries/base$ ghc --make Setup Prelude.hs:38:2: lexical error at character 'i' which is reasonable, because Setup.hs imports Prelude (implicitly), and Prelude.hs was found in the current directory. Prelude.hs has some CPP directives which result in the compilation error. So I could add a warning ("Warning: this Prelude module is shadowing the real Prelude", or something), but then we'd need a new flag to turn off the warning if shadowing the Prelude is what you're really trying to do, and that sounds like an awful lot of bother to fix a very rare corner case. Or can anyone think of a better way to handle this? Cheers, Simon

Jeremy Shaw wrote:
I would still vote for that error in the 'worst ghc error message contest'...
I wrote:
Can't we add something like "(Is there more than one Prelude in your path?)" to the message for Prelude?
Simon Marlow wrote:
So I could add a warning ("Warning: this Prelude module is shadowing the real Prelude", or something), but then we'd need a new flag to turn off the warning if shadowing the Prelude is what you're really trying to do, and that sounds like an awful lot of bother to fix a very rare corner case. Or can anyone think of a better way to handle this?
I was suggesting that whenever the Prelude fails to load, the error message should contain that hint. We'd also like to help rescue people who get weird behavior when, unbeknownst to them, the wrong Prelude loads successfully. But I understand your point that this second case is trickier and may not be worth the effort. Thanks, Yitz

On 03/03/2010 12:37, Yitzchak Gale wrote:
Jeremy Shaw wrote:
I would still vote for that error in the 'worst ghc error message contest'...
I wrote:
Can't we add something like "(Is there more than one Prelude in your path?)" to the message for Prelude?
Simon Marlow wrote:
So I could add a warning ("Warning: this Prelude module is shadowing the real Prelude", or something), but then we'd need a new flag to turn off the warning if shadowing the Prelude is what you're really trying to do, and that sounds like an awful lot of bother to fix a very rare corner case. Or can anyone think of a better way to handle this?
I was suggesting that whenever the Prelude fails to load, the error message should contain that hint.
hmm, I'll think about that. Is it not enough to see a compilation error pointing to the file Prelude.hs?
We'd also like to help rescue people who get weird behavior when, unbeknownst to them, the wrong Prelude loads successfully. But I understand your point that this second case is trickier and may not be worth the effort.
it's probably not that bad, actually: $ ghc --make hello [1 of 2] Compiling Prelude ( Prelude.hs, Prelude.o ) [2 of 2] Compiling Main ( hello.hs, hello.o ) hello.hs:1:8: Not in scope: `putStr' You can pretty clearly see what happened there. Cheers, Simon

I wrote:
I was suggesting that whenever the Prelude fails to load, the error message should contain that hint.
hmm, I'll think about that. Is it not enough to see a compilation error pointing to the file Prelude.hs?
Seems obvious in the context of this thread. But not being in the middle of reading the thread, I am certain that this hint would save me a lot of time and anguish. And it clearly would have done the same for Josef.
it's probably not that bad, actually:
$ ghc --make hello [1 of 2] Compiling Prelude ( Prelude.hs, Prelude.o ) [2 of 2] Compiling Main ( hello.hs, hello.o )
hello.hs:1:8: Not in scope: `putStr'
You can pretty clearly see what happened there.
When something goes wrong with a basic system component like the Prelude, the natural reaction of most people is panic. I've been getting file system corruption lately on a removable hard disk - could it be that? Did I cause this when I moved around some system directories the other day? Are my different copies of GHC getting mixed up with each other's files? It's hard to overestimate how much a soothing message from GHC is appreciated in that kind of situation. Thanks, Yitz
participants (5)
-
Jeremy Shaw
-
Josef Svenningsson
-
Simon Marlow
-
Tom Tobin
-
Yitzchak Gale