jaspervdj / hakyll

A static website compiler library in Haskell
jaspervdj.be/hakyll
Other
2.7k stars 409 forks source link

"The preview server is not enabled in the version of Hakyll" #1022

Closed tomjaguarpaw closed 5 months ago

tomjaguarpaw commented 7 months ago

When using site --watch under hakyll==4.16.2.0 I am getting

The preview server is not enabled in the version of Hakyll. To
enable it, set the flag to True and recompile Hakyll.
Alternatively, use an external tool to serve your site directory.

As a workaround I can set the previewserver flag explicitly, for example

cabal run --constraint="hakyll +previewserver" -- site watch

Firstly, according to https://github.com/jaspervdj/hakyll/issues/298#issuecomment-55239158 I shouldn't need to do this, it should be the default. Does anyone know what's going on?

Secondly, it was really hard to discover the above workaround! Could it be explicitly be added to the error message to give users a clue about what they should do? "set the flag to True and recompile Hakyll" doesn't explain much at all.

Minoru commented 7 months ago

Firstly, according to https://github.com/jaspervdj/hakyll/issues/298#issuecomment-55239158 I shouldn't need to do this, it should be the default. Does anyone know what's going on?

I don't. Is your site's code available anywhere so I can try to reproduce this locally?

Secondly, it was really hard to discover the above workaround! Could it be explicitly be added to the error message to give users a clue about what they should do? "set the flag to True and recompile Hakyll" doesn't explain much at all.

Agreed on that. Do you have a specific wording in mind? I'd review a PR that improves this message.

tomjaguarpaw commented 7 months ago

Is your site's code available anywhere so I can try to reproduce this locally?

Yes, it's https://github.com/tomjaguarpaw/H2, but if you prefer to wait until I submit a minimal example of the problem that's fine too.

Do you have a specific wording in mind?

At the very least I suggest adding this message or linking to one of these GitHub issues that mentions the problem and the fix.

You can set the preview server by running cabal with, e.g. --constraint="hakyll +previewserver"

jaspervdj commented 7 months ago

I also think this is confusing -- I guess the problem is that cabal toggles the flags when it can't find a resolution. Should we set previewServer (and probably watchServer) to Manual: True in the cabal file?

The disadvantage is that instead of seeing this error, the user will see an error that cabal failed to resolve the dependencies...

tomjaguarpaw commented 7 months ago

But in this case cabal can find a resolution, because if I manually set +previewserver then it succeeds.

jstolarek commented 6 months ago

I've run into the same problem - preview server stopped working after rebuilding my website dependencies. Workaround from the first post works, but it isn't an easy thing to figure out. Having this documented would be helpful.

Minoru commented 5 months ago

Fixed by #1024. I'll make a patch release with those improvements after merging the few outstanding PRs and updating some of the dependencies.