堆栈构建失败,由于缺少包,虽然栈ghci的作品 [英] Stack build fails due to missing package although stack ghci works

查看:188
本文介绍了堆栈构建失败,由于缺少包,虽然栈ghci的作品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Haskell中使用堆栈来构建一个简单的程序。我使用 stack new 创建了一个新项目,然后做了一个 stack setup 。模板建立良好。



我想试验二进制文件解析,所以我导入了 Data.ByteString 。我的 build-depends 在cabal文件中看起来像这样:

  build - 取决于:基准> = 4.7&& < 5 
,bytestring> = 0.10.6
,二进制> = 0.7.5

stack ghci 现在可以工作,但是 stack build 仍然不满意。
有人可以告诉我我在这里做错了什么吗?

以下是完整的错误消息:

  test-0.1.0.0:build 
预处理库测试-0.1.0.0 ...
就地注册测试-0.1.0.0 ...
为test-0.1.0.0 ...

haskell / test / app / Main.hs:4:18预处理可执行文件'test-exe':
找不到模块的数据。 ByteString'
它是隐藏包'bytestring-0.10.6.0@bytes_6VWy06pWzJq9evDvK2d4w6'的成员。
也许你需要在你的.cabal文件中添加'bytestring'到build-depends。
使用-v查看搜索的文件列表。

haskell / test / app / Main.hs:5:8:
无法找到模块'Data.Binary.Get'
它是隐藏包' binary-0.7.5.0@binar_3uXFWMoAGBg0xKP9MHKRwi。
也许你需要在你的.cabal文件中为build-depends添加'binary'。
使用-v查看搜索的文件列表。

- 使用以下命令构建软件包测试-0.1.0.0:
.stack / setup-exe-cache / x86_64-osx / setup-Simple-Cabal-1.22.5.0-ghc-7.10 .3 --builddir = .stack-work / dist / x86_64-osx / Cabal-1.22.5.0 build lib:test exe:test-exe --ghc-options-ddump-hi -ddump-to-file
Process退出代码:ExitFailure 1

这是我的app / Main.hs文件:

 模块Main其中

导入Lib
将限定的Data.ByteString导入为B
import Data.Binary.Get
import Data.Word
$ b $ main main :: IO()
main = do
putStrLnf
<

解决方案

/ div>

这很可能是因为您向库的 build-depends 添加了 bytestring ,而不是可执行文件。避免需要重复这些不同节的依赖关系的一个选择是使用 hpack 作为包描述格式。

I am trying to build a simple program in Haskell using stack. I created a new project using stack new and did a stack setup after that. The template builds fine.

I want to experiment with binary file parsing, so I imported Data.ByteString. My build-depends in the cabal file look like this:

build-depends:     base >= 4.7 && < 5
                 , bytestring >= 0.10.6
                 , binary >= 0.7.5

stack ghci now just works, but stack build is still not happy. Can someone tell me what I did wrong here?

Here is the complete error message:

test-0.1.0.0: build
Preprocessing library test-0.1.0.0...
In-place registering test-0.1.0.0...
Preprocessing executable 'test-exe' for test-0.1.0.0...

haskell/test/app/Main.hs:4:18:
    Could not find module ‘Data.ByteString’
    It is a member of the hidden package ‘bytestring-0.10.6.0@bytes_6VWy06pWzJq9evDvK2d4w6’.
    Perhaps you need to add ‘bytestring’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.

haskell/test/app/Main.hs:5:8:
    Could not find module ‘Data.Binary.Get’
    It is a member of the hidden package ‘binary-0.7.5.0@binar_3uXFWMoAGBg0xKP9MHKRwi’.
    Perhaps you need to add ‘binary’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.

--  While building package test-0.1.0.0 using:
      .stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 build lib:test exe:test-exe --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

and this is my app/Main.hs file:

module Main where

import Lib
import qualified Data.ByteString as B
import Data.Binary.Get
import Data.Word

main :: IO ()
main =  do
    putStrLn "f"

Thank you very much for your help.

解决方案

This is likely because you added bytestring to the build-depends of the library, not the executable. One option to avoid needing to repeat these dependencies for the different stanzas is to use hpack as the package description format.

这篇关于堆栈构建失败,由于缺少包,虽然栈ghci的作品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆