隐藏包二进制-0.7.5.0?

Ryo*_*Oka 2 haskell haskell-stack

我收到此错误:

Could not find module ‘Data.Binary’
It is a member of the hidden package ‘binary-0.7.5.0@binar_IvYoLp9H6Xy3zEH13MmZwd’.
Run Code Online (Sandbox Code Playgroud)

当我Data.Binary使用GHCi版本7.10.2 导入我的堆栈项目时.

奇怪的是,如果我执行GHCi,这不会出现stack exec ghci,并且我无法binary通过堆栈安装更新版本的包,它看起来:

D:\p>stack install binary
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the install command is functionally equivalent to 'build --copy-bins'

D:\p>stack install binary-0.7.6.1
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the install command is functionally equivalent to 'build --copy-bins'
Error parsing targets: Specified target version 0.7.6.1 for package binary does not match snapshot version 0.7.5.0

D:\p>stack install binary-0.7.5.0
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the install command is functionally equivalent to 'build --copy-bins'
Run Code Online (Sandbox Code Playgroud)

你会如何解决这个问题?

jos*_*uan 5

添加binary依赖项到您的cabal文件.

build-depends:       base >= 4.7 && < 5
                   , binary >= 0.7.5
Run Code Online (Sandbox Code Playgroud)

当您使用时,stack install您正在安装某些库或可执行文件但不是作为依赖项(例如,yesod您只在内部使用的实用程序或某些库ghci...).

  • 另外一点:向.cabal文件添加依赖项实际上是使用堆栈安装库的主要方法.添加依赖项后,它将在第一次需要时自动安装(例如,当您运行`stack build`时). (4认同)