I'm trying to write a myproj.cabal
file for my project, but it doesn't seem to be locating packages I've installed in 开发者_StackOverflow中文版~/.cabal
% cabal list HTF
* HTF
Synopsis: The Haskell Test Framework
Latest version available: 0.6.0.1
Latest version installed: 0.6.0.1
License: LGPL
% ghc-pkg list HTF
/Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.3/package.conf.d
/Users/rampion/.ghc/i386-darwin-6.12.3/package.conf.d
HTF-0.6.0.1
% cat Setup.hs
import Distribution.Simple
main = defaultMain
% cat Clue.cabal
...
executable clue-tests
ghc-options: -Wall -F -pgmF htfpp
build-depends: QuickCheck, HTF
main-is: Tests.hs
hs-source-dirs: tests src
% runhaskell Setup.hs configure
Configuring Clue-0.1.0...
Setup.hs: At least the following dependencies are missing:
HTF -any
What am I doing wrong here?
User rampion has given the long answer.
The short answer is that if you use 'cabal configure' and 'cabal build' and 'cabal install' instead of 'runghc Setup.hs configure' everything will work out nicer.
Hey, it's covered in the FAQ!
The default for runghc Setup.hs configure is --global, but the default for cabal configure is --user. Global packages cannot depend on user packages. So if you're using the cabal program to install packages, then you can also us it to configure other packages. There is usually no need to use runghc Setup.hs at all.
If you need to use the runghc Setup.hs interface (e.g. in some system build scripts) and you want it to pick up packages from the user package db then use the --user flag. If you're constantly having to use the runghc Setup.hs interface and doing per-user installs is a pain then you can set the default for the cabal program to be global installs in the cabal config file (~/.cabal/config).
精彩评论