ghc 找不到我的 cabal 安装的软件包
我安装了 ghc 6.12.3,然后安装了 Haskell Platform。我正在尝试编译一个测试程序:
$ ghc test.hs
test.hs:3:0:
Failed to load interface for `Bindings':
Use -v to see a list of the files searched for.
所以,自然地,我做
cabal install Bindings
的工作正常,并将包放在 ~/.cabal/lib/bindings-0.1.2 问题是,当我用 ghc 再次编译时,它仍然没有找到我用 cabal 安装的包。 在详细模式下编译给出:
ghc -v test.hs
Using binary package database: /home/ludflu/ghc/lib/ghc-6.12.3/package.conf.d/package.cache
Using binary package database: /home/ludflu/.ghc/x86_64-linux 6.12.3/package.conf.d/package.cache
正如另一个 stackoverflow 用户所建议的,我尝试过:
ghc-pkg describe rts > rts.pkg
vi rts.pkg # add the /home/ludflu/.cabal/lib to `library-dirs` field
ghc-pkg update rts.pkg
但无济于事。如何将 .cabal 添加到要搜索的包目录列表中? 谢谢你!
I've installed ghc 6.12.3, and then the Haskell Platform. I'm trying to compile a test program:
$ ghc test.hs
test.hs:3:0:
Failed to load interface for `Bindings':
Use -v to see a list of the files searched for.
so, naturally, I do
cabal install Bindings
Which works fine, and places the package in ~/.cabal/lib/bindings-0.1.2 The problem is, that when I go to compile again with ghc, it still doesn't find the package I've installed with cabal.
compiling in verbose mode gives:
ghc -v test.hs
Using binary package database: /home/ludflu/ghc/lib/ghc-6.12.3/package.conf.d/package.cache
Using binary package database: /home/ludflu/.ghc/x86_64-linux 6.12.3/package.conf.d/package.cache
As suggested by another stackoverflow user, I tried:
ghc-pkg describe rts > rts.pkg
vi rts.pkg # add the /home/ludflu/.cabal/lib to `library-dirs` field
ghc-pkg update rts.pkg
But to no avail. How to I add the .cabal to the list of package directories to search?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 ghc-pkg list 检查安装了哪些软件包。您可能需要使用
-package
将软件包指定为ghc
,或者我相信添加--make
将触发对依赖项(包括包)的追踪。编辑:绑定包确实已过时,请参阅黑客页面< /a>.这不是包管理问题,唯一可用的模块是 Bindings.Deprecated,您完全可以加载它,即使它是一个空模块。我相信相关部分已分解为
bindings-
,因此如果您需要绑定功能,您应该查看这些包。You can check which packages are installed with
ghc-pkg list
. It may be that you need to either specify the packages toghc
with-package <pkgname>
or I believe adding--make
to will trigger a chasing down of dependencies, including packages.Edit: the bindings package is obsolete indeed, see the hackage page. This isn't a package management problem, the only module available is
Bindings.Deprecated
, which you are perfectly able to load, even though it is an empty module. I believe the relevant parts have been broken out intobindings-<module>
, so if you want the bindings functionality you should look to those packages.http://www.haskell.org/haskellwiki/Cabal-install
一件事是特别要注意的是,cabal 默认情况下在本地安装软件包,而
默认情况下命令全局安装。如果全局安装软件包,则本地软件包将被忽略。 cabal-install 的默认设置可以通过编辑配置文件来修改。
我在使用 runhaskell 命令时遇到了同样的错误。我在包含 .cabal 文件的目录中使用了 cabal,并且能够解决该错误。
http://www.haskell.org/haskellwiki/Cabal-install
One thing to be especially aware of, is that the packages are installed locally by default by cabal, whereas the commands
install globally by default. If you install a package globally, the local packages are ignored. The default for cabal-install can be modified by editing the configuration file.
I was getting the same error with the
runhaskell
command. I used the cabal in the directory that had the .cabal file and was able to resolve the error.