Pandoc“找不到模块...”已安装的模块

乌利·科勒(Uli Koehler)

我目前正在尝试使用pandoc(作为Haskell模块,而不是程序)将MediaWiki文本转换为其他格式。

让我们假设这个程序:

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

当使用runghc运行它,我得到以下错误信息:

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

我的第一个假设是未安装pandoc或未正确安装pandoc。因此,我用--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

的输出runghc -v pandock.hs相当长,我假设相关部分是:

*** 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.

但是,两者~/.cabal/lib/x86_64-linux-ghc-7.6.3/pandoc-1.12.3.1/Text/Pandoc/Readers/Mediawiki/MediaWiki.hi~/.cabal/bin/pandoc存在。如何使GHC正确识别已cabal安装的软件包?

任何帮助将不胜感激!

乌利·科勒(Uli Koehler)

尝试在其他计算机上重现此问题时,每5台计算机中只有2台出现此问题。在它们两个上,我都以相同的方式和顺序安装了cabal软件包。

回想起来,我认为这个问题是由于某些破损的包装造成了严重破坏而出现的:

$ 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

请注意,此处pandoc没有列出yaml没有(我在问完问题后安装了它,并且与完全一样pandoc))。

对于也有类似问题的用户,请确保:

  1. 该软件包已安装,并且您不在任何未安装该软件包的沙箱中。

  2. 在执行测试脚本的目录中,确保没有Text/Pandoc文件夹(或等效文件夹,具体取决于引起问题的软件包)

  3. 运行您的测试脚本runghc -v以检查它是否搜索正确的目录

  4. ghc-pkg list列出您已安装的软件包,没有损坏的软件包(用于ghc-pkg check检查)

我通过重命名~/.cabal解决了我的问题~/.ghc请注意,我这样做时缺乏适当的解决方案,我认为您应该只在万不得已时才这样做。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章