Pandoc 'Could not find module …' for installed module

倾然丶 夕夏残阳落幕 提交于 2021-01-27 06:31:36

问题


I'm currently trying to use pandoc (as a Haskell module, not as a program) to convert MediaWiki text to other formats.

Let's assume this program:

 import Text.Pandoc.Readers.MediaWiki
 main = do print "foo"

When using runghc to run it, I get the following error message:

pandock.hs:1:8:
    Could not find module `Text.Pandoc.Readers.MediaWiki'
    Use -v to see a list of the files searched for.

My first assumption was that pandoc was either not installed or incorrectly installed. Therefore I reinstalled it with --force-reinstalls

$ cabal install pandoc --reinstall
[...]
In order, the following will be installed:
pandoc-1.12.3.1 (reinstall) changes: old-time-1.1.0.1 added
[...]
[32 of 55] Compiling Text.Pandoc.Readers.MediaWiki ( src/Text/Pandoc/Readers/MediaWiki.hs, dist/build/Text/Pandoc/Readers/MediaWiki.o )
[...]
Installing library in
/home/uli/.cabal/lib/x86_64-linux-ghc-7.6.3/pandoc-1.12.3.1
Installing executable(s) in /home/uli/.cabal/bin
Registering pandoc-1.12.3.1...
Installed pandoc-1.12.3.1

The output of runghc -v pandock.hs is quite long, I assume the relevant part is:

*** Chasing dependencies:
Chasing modules from: *pandock.hs

pandock.hs:1:8:
    Could not find module `Text.Pandoc.Readers.MediaWiki'
    Locations searched:
      Text/Pandoc/Readers/MediaWiki.hs
      Text/Pandoc/Readers/MediaWiki.lhs
Failed, modules loaded: none.

However, both ~/.cabal/lib/x86_64-linux-ghc-7.6.3/pandoc-1.12.3.1/Text/Pandoc/Readers/Mediawiki/MediaWiki.hi and ~/.cabal/bin/pandoc exist. How can I make GHC properly recognize the cabal-installed package?

Any help will be appreciated!


回答1:


When trying to reproduce this issue on other computers, only 2 out of 5 computers had this issue. On both of them I installed cabal packages in about the same way and order.

In retrospect I assume this issue arose because of some broken packages wreaking havoc:

$ ghc-pkg check
There are problems in package feed-0.3.9.2:
  dependency "xml-1.3.13-dd52b1688e97a3c6cd0aa48dba7b153e" doesn't exist
There are problems in package hxt-9.3.1.3:
  dependency "network-2.4.2.2-ea77cdf1bc747bc58308fdeb52745c4d" doesn't exist
There are problems in package hspec-1.8.1.1:
  dependency "QuickCheck-2.6-409fcc32c191cd6e04afdebb15869820" doesn't exist
There are problems in package quickcheck-io-0.1.0:
  dependency "QuickCheck-2.6-409fcc32c191cd6e04afdebb15869820" doesn't exist
There are problems in package regex-compat-0.95.1:
  dependency "regex-base-0.93.2-2023953b859e6f91efe89733d2ef5421" doesn't exist
There are problems in package regex-posix-0.95.2:
  dependency "regex-base-0.93.2-2023953b859e6f91efe89733d2ef5421" doesn't exist
There are problems in package hxt-9.3.1.2:
  dependency "network-2.4.2.2-ea77cdf1bc747bc58308fdeb52745c4d" doesn't exist

The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
feed-0.3.9.2
hxt-9.3.1.3
hspec-1.8.1.1
quickcheck-io-0.1.0
regex-compat-0.95.1
regex-posix-0.95.2
hxt-9.3.1.2
MissingH-1.2.0.2
yesod-test-1.2.1

Note that neither pandoc nor yaml (I installed it after asking the question and had the exact same issues as with pandoc) are listed there.

For users also having a similar problem, please ensure:

  1. The package is installed and you're not inside any sandbox where the package is not installed.

  2. In the directory where you're executing the test script, ensure that there is no Text/Pandoc folder (or equivalent, depending on the package causing the problem

  3. Run your test script with runghc -v to check if it searches the proper directory

  4. ghc-pkg list lists your package as installed, and no packages are broken (use ghc-pkg check to check)

I solved my problem by renaming ~/.cabal and ~/.ghc. Note that I did this lacking a proper solution, I think you should only do this as a last resort.



来源:https://stackoverflow.com/questions/21273070/pandoc-could-not-find-module-for-installed-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!