【发布时间】:2015-02-21 13:08:56
【问题描述】:
我安装了图表,它似乎在那里,但 GHCi 没有找到它。我尝试将本地沙箱添加到命令行(-package-db),但仍然没有运气。 有什么建议吗?
C:\Users\guthrie>
C:\Users\guthrie>cabal install diagrams
Resolving dependencies...
All the requested packages are already installed:
diagrams-1.2
Use --reinstall if you want to reinstall anyway.
我在以下位置找到它:
C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d
(diagrams-1.2, diagrams-contrib, -core, -lib, -svg)
但正在运行:“cabal repl”或使用 GHC(i) 标志“-package-db=...” 没找到:
C:\Users\guthrie>cabal repl
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m + Diagrams.Prelude
<no location info>:
Could not find module `Diagrams.Prelude'
It is not a module in the current program, or in any known package.
Prelude>
澄清;忽略 cabal 调用,直接使用 GHC/i 和程序 diagramsDemo.hs:
-- http://projects.haskell.org/diagrams/doc/quickstart.html
--
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine
main = mainWith (circle 1 :: Diagram B R2)
给予:
C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs
diagramsDemo.hs:7:8:
Could not find module `Diagrams.Backend.SVG.CmdLine'
Use -v to see a list of the files searched for.
C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs -package-db=C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d
diagramsDemo.hs:7:8:
Could not find module `Diagrams.Backend.SVG.CmdLine'
Use -v to see a list of the files searched for.
【问题讨论】:
-
如果
diagrams包未在您的.cabal文件中指定为依赖项,则它将无法从cabal repl获得(错误功能,IMO)。您可以使用ghci -no-user-package-db -package-db=./.cabal-sandbox/i386-windows-ghc-7.6.3-packages.conf.d解决此问题,我在安装 cygwin bash 时为其设置了别名。 -
谢谢 - 但忽略 cabal-repl 方法,似乎 ghci -package-db=... 应该足以让 ghc/i 找到它。我在相邻的机器上有相同的应用程序,它工作正常,可以找到任何/所有已安装的包。所以问题是为什么 -db 参数不足以找到它,当 cabal install 时。
-
当您使用
cabal repl时,它会加载您为项目指定的依赖项。您绝对可以将其他软件包安装到沙箱中,但这并不意味着它们可以导入。-package-db标志添加了一个额外的包数据库,以便在 ghci 查找包时进行扫描,但我也更喜欢-no-user-package-db标志,因为它可以防止与我的 cabal 系统安装发生冲突。
标签: haskell cabal cabal-install