在OS X 10.9(Mavericks)上安装HaXml遇到的问题

4
我在我的系统上安装HaXml遇到了麻烦。
我已经安装了Haskell平台并使用了以下链接提供的clang-wrapper补丁:http://www.haskell.org/platform/mac.html 当我尝试运行cabal install HaXml时,我会得到以下错误。我已经尽力进行了一些研究,但仍然无法解决这个问题。我甚至尝试了在此链接http://hackage.haskell.org/package/HaXml中找到的依赖项,然后尝试安装软件包,但仍然没有成功。我在终端中收到以下错误消息:
Resolving dependencies...
Configuring HaXml-1.24...

/var/folders/m0/w93djnj57fv4wynyrjf4lgxc0000gn/T/23529.c:1:12:
     warning: control reaches end of non-void function [-Wreturn-type]
int foo() {}
           ^
1 warning generated.
Building HaXml-1.24...
Preprocessing library HaXml-1.24...
[ 1 of 42] Compiling Text.XML.HaXml.Xtract.Lex ( src/Text/XML/HaXml/Xtract/Lex.hs, dist/build/Text/XML/HaXml/Xtract/Lex.o )
[ 2 of 42] Compiling Text.XML.HaXml.DtdToHaskell.TypeDef ( src/Text/XML/HaXml/DtdToHaskell/TypeDef.hs, dist/build/Text/XML/HaXml/DtdToHaskell/TypeDef.o )
[ 3 of 42] Compiling Text.XML.HaXml.DtdToHaskell.Instance ( src/Text/XML/HaXml/DtdToHaskell/Instance.hs, dist/build/Text/XML/HaXml/DtdToHaskell/Instance.o )
[ 4 of 42] Compiling Text.XML.HaXml.Posn ( src/Text/XML/HaXml/Posn.hs, dist/build/Text/XML/HaXml/Posn.o )
[ 5 of 42] Compiling Text.XML.HaXml.Lex ( src/Text/XML/HaXml/Lex.hs, dist/build/Text/XML/HaXml/Lex.o )
[ 6 of 42] Compiling Text.XML.HaXml.Types ( src/Text/XML/HaXml/Types.hs, dist/build/Text/XML/HaXml/Types.o )
[ 7 of 42] Compiling Text.XML.HaXml.Namespaces ( src/Text/XML/HaXml/Namespaces.hs, dist/build/Text/XML/HaXml/Namespaces.o )
[ 8 of 42] Compiling Text.XML.HaXml.Schema.XSDTypeModel ( src/Text/XML/HaXml/Schema/XSDTypeModel.hs, dist/build/Text/XML/HaXml/Schema/XSDTypeModel.o )

src/Text/XML/HaXml/Schema/XSDTypeModel.hs:305:19: Warning:
    Fields of `Schema' not initialised: schema_elementFormDefault,
                                        schema_attributeFormDefault, schema_finalDefault,
                                        schema_blockDefault, schema_targetNamespace, schema_version,
                                        schema_namespaces
    In the expression: Schema {schema_items = []}
    In an equation for `mempty': mempty = Schema {schema_items = []}
    In the instance declaration for `Monoid Schema'
[ 9 of 42] Compiling Text.XML.HaXml.Schema.PrimitiveTypes ( src/Text/XML/HaXml/Schema/PrimitiveTypes.hs, dist/build/Text/XML/HaXml/Schema/PrimitiveTypes.o )
[10 of 42] Compiling Text.XML.HaXml.Verbatim ( src/Text/XML/HaXml/Verbatim.hs, dist/build/Text/XML/HaXml/Verbatim.o )
[11 of 42] Compiling Text.XML.HaXml.Combinators ( src/Text/XML/HaXml/Combinators.hs, dist/build/Text/XML/HaXml/Combinators.o )
[12 of 42] Compiling Text.XML.HaXml.Parse ( src/Text/XML/HaXml/Parse.hs, dist/build/Text/XML/HaXml/Parse.o )
[13 of 42] Compiling Text.XML.HaXml.Pretty ( src/Text/XML/HaXml/Pretty.hs, dist/build/Text/XML/HaXml/Pretty.o )
[14 of 42] Compiling Text.XML.HaXml.Html.Generate ( src/Text/XML/HaXml/Html/Generate.hs, dist/build/Text/XML/HaXml/Html/Generate.o )
[15 of 42] Compiling Text.XML.HaXml.Html.Parse ( src/Text/XML/HaXml/Html/Parse.hs, dist/build/Text/XML/HaXml/Html/Parse.o )
[16 of 42] Compiling Text.XML.HaXml.Wrappers ( src/Text/XML/HaXml/Wrappers.hs, dist/build/Text/XML/HaXml/Wrappers.o )

src/Text/XML/HaXml/Wrappers.hs:34:36:
    Couldn't match type `[Char]' with `b0 -> c0'
    Expected type: b0 -> c0
      Actual type: String
    In the return type of a call of `show'
    Probable cause: `show' is applied to too many arguments
    In the first argument of `(.)', namely `show 1'
    In the second argument of `(++)', namely `show 1 . 24'

src/Text/XML/HaXml/Wrappers.hs:34:36:
    Couldn't match expected type `[Char]' with actual type `a0 -> c0'
    In the second argument of `(++)', namely `show 1 . 24'
    In the second argument of `($)', namely
      `"part of HaXml-" ++ show 1 . 24'
    In a stmt of a 'do' block:
      putStrLn $ "part of HaXml-" ++ show 1 . 24
Failed to install HaXml-1.24
cabal: Error: some packages failed to install:
HaXml-1.24 failed during the building phase. The exception was:
ExitFailure 1

帮忙!

1个回答

6
我知道问题出在哪里,但不知道有什么好的解决方案。
问题出在 src/Text/XML/HaXml/Wrappers.hs 文件中。(顺便说一下,你可以通过输入“cabal unpack ”来轻松查看 cabal 的源代码,然后进入新创建的目录)。如果你查看该文件,会发现它使用了 ghc 语言扩展,在实际编译之前添加了 c 风格的预处理。在这种情况下,它被用于将构建版本号插入到源代码中... 这是这一行:
putStrLn $ "part of HaXml-"++show MAJOR.MINOR

如果你在源代码中使用grep命令,就可以看到"MAJOR"和"MINOR"宏的添加位置。

> grep -r MAJOR *
HaXmL.cabal: cpp-options: -DMAJOR=1 -DMINOR=24

这个机制在我的Linux电脑上运行良好... Wrappers.hs中的这一行会扩展为:
putStrLn $ "part of HaXml-"++show 1.24

根据您上面展示的错误信息,您的Mac扩展实际上正在变得...
putStrLn $ "part of HaXml-"++show 1 . 24

差别微小,但影响巨大。由于多余的空格,版本号未被解析为Float,"."已成为中缀组合运算符,并期望"1"和"24"是要组合的函数!这可能是构建过程中的一个错误....
我目前无法访问Mac进行进一步调试(正如我之前提到的,这在我的Linux设备上编译),但你有以下选项:
1.向HaXmL团队提交错误报告,并等待他们修复它(如果我今天后面感到有动力,我也可能这样做)。显然,这可能需要一些时间。
2.如果有其他操作系统可以使用,则可使用另一个操作系统。
3.如果您只想将东西启动并运行,可以进行小的修复并自行构建。
这比听起来容易得多。只需执行以下操作:
> cabal unpack HaXmL
> cd HaXmL-1.24

现在编辑 src/Text/XML/HaXml/Wrappers.hs 文件,并手动输入版本号(例如,将 "MAJOR.MINOR" 改为 "1.24")(也是 src/Text/XML/HaXml.hs 文件)。继续操作,请键入

> cabal configure
> cabal build
> cabal install

这最后的三行可以由最后一行 "cabal install" 替换,但是由于你正在调试,我认为分别输入每一行更容易隔离问题。

如果这能够正常工作,你应该会得到一个可用的 HaXmL 版本。当然,这并不是一个长久之计(即每次升级都要重复此过程),但有时这是快速开始的唯一方式。


+1,超级棒的努力,非常好、有用的回答。你正在让互联网变得更好。 - not my job
很好的回答。我在本地修复了这个问题,并向HaXml维护者Malcolm Wallace提交了一个补丁。如果有其他人需要在上游修复之前解决此问题,这是补丁文件 - Justin Leitgeb

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接