问题
So I'm trying to use reactive-banana + wxHaskell for GUI programming. As a newbie to Haskell and its dev tools, I'm very perplexed by stack.
So I try stack install wx
, which prompts me to install wxcore
, which prompts me to install wxc
and wxdirect
. After I stack install wxdirect
, I try running stack install wxc
, but lo and behold:
While constructing the BuildPlan the following exceptions were encountered:
-- Failure when adding dependencies:
wxdirect: needed (>=0.90.1.1), not present in build plan (latest is 0.92.1.0)
needed for package: wxc-0.92.1.1
-- While attempting to add dependency,
Could not find package wxdirect in known packages
Recommended action: try adding the following to your extra-deps in {project root}/stack.yaml
- wxdirect-0.92.1.0
In short I'm trying to use stack
like cabal-install
. And I'm not sure why this is wrong. And if it is wrong, then what's the difference between stack
and cabal-install
?
回答1:
The difference between stack and cabal install is that stack requires a curated list of (package, version). The upshot is that stack will make sure that those packages at those version will all compile and be cheerful. It seems like wxdirect isn't in the curated list yet though. You should file a PR with stackage, which is a great thing to do as it'll fix this problem for other users as well.
You can also take the advice given in the last couple lines:
Recommended action: try adding the following to your extra-deps in {project root}/stack.yaml
- wxdirect-0.92.1.0
And modify your stack.yaml file. Change the default
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps: []
To
extra-deps:
- wxdirect-0.92.1.0
stack will now attempt an install pretending as if that (package, version) had made it onto the curated list.
You might still run into the following problems though.
I don't have a stack.yaml
If you aren't in a a project (and you want to stack install a package to the user database, a thing that cabal install would do silently), you'll run into this. This is one of the differences between stack and cabal install, but it's a good one: cabal installing a package just puts it into the global database. This is great until packages need to be updated. With stack, you're always in a project. If you run stack outside a project with a stack.yaml, stack will consult your ~/.stack/global/stack.yaml
. Just stick the extra-deps there.
It won't build
Make sure you stack upgrade and you're using the latest LTS version in resolver:
, another field in stack.yaml
. This ensures you have the most recent curation.
It still won't build
You might have to try an older version of wxdirect. Stackage packages are sometimes, but not usually, lagging behind the last release on every package.
It still still won't build
You might have run into an issue with stack. I've seen stack bugs before. You can ask on the IRC channel too. And if that doesn't work, just badger Edward Kmett on /r/haskell and he'll solve it with mathematics.
来源:https://stackoverflow.com/questions/34009800/why-does-stack-not-recognize-the-dependency-it-just-installed