ndmitchell / ghcid

Very low feature GHCi based IDE
Other
1.13k stars 114 forks source link

Better error message than "No files loaded, GHCi is not working properly."? #348

Closed tomjaguarpaw closed 2 years ago

tomjaguarpaw commented 2 years ago

If I run

ghcid --command=ghci

without a .ghci file then I get the error message

No files loaded, GHCi is not working properly.

Firstly, this is quite alarming. Secondly, I don't think it's correct. GHCi is working fine but it hasn't been correctly configured to work with ghcid. Would you be open to a different error message? I'm not sure I know ghcid well enough to be able to make a good suggestion, but maybe something like:

GHCi didn't load any files. Do you have a .ghci file? Make one
and put in it, for example

:load Path/To/Main.hs

(ghcid could even check for the existence of that .ghci file.)

ndmitchell commented 2 years ago

The number of people using .ghci files is decreasing rapidly because Cabal doesn't support them very well, thus I don't think that for most people specifying ghci files is a good idea. Unfortunately, there is no blanket answer as for how to configure things properly, and I don't think there will be for a while. I tweaked the message to:

No files loaded, GHCi not configured properly.

But I don't have anything better than that...

tomjaguarpaw commented 2 years ago

The number of people using .ghci files is decreasing rapidly because Cabal doesn't support them very well, thus I don't think that for most people specifying ghci files is a good idea.

I see. Perhaps it's a particularity of my setup that the "ghci wrapper" I provide doesn't load a module.

I tweaked the message to:

No files loaded, GHCi not configured properly.

But I don't have anything better than that...

How about saying exactly what the problem is? Something like "When ghcid runs the command that provides it with a GHCi session, that GHCi session must to load a module, but it didn't.". Then at least people have something to work with. "Not configured properly" just raises more questions.

ndmitchell commented 2 years ago
No files were loaded by the supplied ghci command, which isn't allowed (no files to watch).

Thoughts?

ndmitchell commented 2 years ago

Perhaps it's a particularity of my setup that the "ghci wrapper" I provide doesn't load a module.

I think most people use cabal repl or stack repl nowadays which might not load any modules, but usually due to errors in the setup rather than a missing .ghci :load entry.

tomjaguarpaw commented 2 years ago

No files were loaded by the supplied ghci command, which isn't allowed (no files to watch).

Thoughts?

Sounds good, though I'd probably suggest replacing "isn't allowed" to "means I can't do anything". It's not really forbidden it just doesn't do anything useful.

Perhaps it's a particularity of my setup that the "ghci wrapper" I provide doesn't load a module.

I think most people use cabal repl or stack repl nowadays which might not load any modules, but usually due to errors in the setup rather than a missing .ghci :load entry.

I see. Work has some Nix-based ghci wrapper and I guess it just doesn't load any modules unless I configure a .ghci file.

ndmitchell commented 2 years ago

It isn't allowed and will cause ghcid to abort (technically ghcid could just sit their watching no files, but while it is the correct zero-case behaviour, it's not actually what anyone wants)

tomjaguarpaw commented 2 years ago

It isn't allowed and will cause ghcid to abort (technically ghcid could just sit their watching no files, but while it is the correct zero-case behaviour, it's not actually what anyone wants)

Sure, but the user's next question will be "why isn't it allowed?" and the answer is "because if you don't load any modules then ghcid isn't useful". I'd suggest avoiding having the user ask themselves that question but just answering it directly in the error message.

Anyway, any of the messages we've suggested in this thread are better than the status quo.

ndmitchell commented 2 years ago
No files loaded, meaning ghcid will never refresh, so aborting.

Thoughts?

tomjaguarpaw commented 2 years ago

I like that one!

ndmitchell commented 2 years ago

Done! Thanks for your help refining this bit