How do I tell gitit plugins where the libraries are?

Viewed 115

Short version

I configured gitit to use its “Deprofanizer” plugin, but when I ran it, it failed, saying:

Loading plugin 'plugins/Deprofanizer.hs'...

plugins/Deprofanizer.hs:6:1: error:
    Could not find module ‘Network.Gitit.Interface’
    Use -v to see a list of the files searched for.
  |
6 | import Network.Gitit.Interface
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gitit: Error loading plugin: plugins/Deprofanizer.hs

Apparently it found the plugin, but then couldn't compile it.

How do I fix this?

Longer detailed version

I've installed the gitit wiki software according to the instructions, using stack install. If I just run gitit, it works perfectly: it creates its static directory, initializes its database, and runs an HTTP service on port 5001, just as advertised.

But I can't get the plugins to work, for what seems to be a purely configuration-related issue.

The sample gitit configuration contains an explanation of how to configure plugins:

plugins:
# specifies a list of plugins to load.  Plugins may be specified
# either by their path or by their module name.  If the plugin name
# starts with Gitit.Plugin., gitit will assume that the plugin is
# an installed module and will not try to find a source file.
# Examples:
# plugins: plugins/DotPlugin.hs, CapitalizeEmphasisPlugin.hs
# plugins: plugins/DotPlugin
# plugins: Gitit.Plugin.InterwikiLinks

The default configuration uses no plugins. Several plugins are supplied with gitit, and the instructions here seem clear, so I tried turning on the Deprofanizer plugin by changing the plugins configuration to:

    plugins: plugins/Deprofanizer.hs

as the sample suggested. (Deprofanizer is provided with gitit as an example.)

This almost works. When I start up gitit, it does locate the Deprofanizer module where I expect, and it attempts to compile it. But:

Loading plugin 'plugins/Deprofanizer.hs'...

plugins/Deprofanizer.hs:6:1: error:
    Could not find module ‘Network.Gitit.Interface’
    Use -v to see a list of the files searched for.
  |
6 | import Network.Gitit.Interface
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gitit: Error loading plugin: plugins/Deprofanizer.hs

The Network.Gitit.Interface module is indeed part of the Gitit distribution, and I suppose it is compiled into my gitit executable. But I don't know why the plugin can't import it, or how to fix it. I can't find any hint in the manual that this might be a problem.

I found the code (in Network.Gitit.Plugins responsible for loading and compiling the plugin module:

    loadPlugin pluginName = do
      logM "gitit" WARNING ("Loading plugin '" ++ pluginName ++ "'...")
      runGhc (Just libdir) $ do
          ...

and instrumented it to write out the value of libdir, which is /home/mjd/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5. This directory exists, but I don't know what to do with it.

So again, the question is:

How do I fix this?

0 Answers
Related