stack.yaml没有从GitHub拉取依赖项。

3
这是 stack.yaml 的部分内容: packages:
- location:
   git: https://github.com/TwitterFriends/lsh.git
   commit: 57d57f4209e56f526c0eca023907015935c26071
   extra-dep: true

我将包添加到Cabal文件中

尝试构建时出现错误

While constructing the BuildPlan the following exceptions were encountered:

--  While attempting to add dependency,
    Could not find package lsh in known packages

我做错了什么?

当前项目在这里找到

https://github.com/TwitterFriends/twitter-friend-server

2个回答

4
问题在于语法。你在extra-dep之前添加了一些额外的空格。把这个部分放到stack.yaml中。这样,在我机器上就能成功构建你的项目了。
- location:
    git: https://github.com/TwitterFriends/lsh.git
    commit: 57d57f4209e56f526c0eca023907015935c26071
  extra-dep: true

更新: (2017年12月17日)

自从stack-1.6.1版本以来,添加github依赖的语法已经改变。你需要将你的github依赖添加到extra-deps字段中。示例如下:

resolver: lts-9.17
packages: [.]

extra-deps:
- fmt-0.5.0.0
- git: https://github.com/TwitterFriends/lsh.git
  commit: 57d57f4209e56f526c0eca023907015935c26071

更新:(2019年12月5日)

stack-2.1.3版本中,您可以使用更短的语法在extra-deps中指定GitHub依赖项:

extra-deps:
- github: TwitterFriends/lsh
  commit: 57d57f4209e56f526c0eca023907015935c26071

lsh包被注释在了.cabal文件中。我取消了注释,但是遇到了同样的问题。尝试进行git pull以查看更改。 - user1198582
我不知道现在这里出了什么问题。对我来说,这是一个谜。但我注意到你有两个packages元素。尝试删除两个packages并仅添加此内容:http://lpaste.net/6027187186263130112 现在它为我找到了lsh包。另外,在此之前不要忘记执行stack clean,有时可能会有所帮助。 - Shersh

1
看起来,你面临的问题是由于你在发布问题时所贴代码的stack.yaml文件中的几行存在语法错误所致。
当我访问了你的仓库并检查了整个stack.yaml文件后,我发现了这个问题:
resolver: lts-8.13

# User packages to be built.
# Various formats can be used as shown in the example below.
# 
packages:

# - https://example.com/foo/bar/baz-0.0.2.tar.gz
- location:
    git: https://github.com/TwitterFriends/lsh.git
    commit: 57d57f4209e56f526c0eca023907015935c26071
  extra-dep: true

这个packages:行看起来不对,特别是考虑到文件后面你有:

packages:
- '.'

所以我最好的猜测是,stack.yaml文件没有被正确解析,因此它无法找到库,因为它不知道应该从那个位置获取。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接