gpt4 book ai didi

haskell - 在 Haskell Stack 项目中构建 yesod/amazonka 依赖项时遇到问题

转载 作者:行者123 更新时间:2023-12-02 12:07:53 25 4
gpt4 key购买 nike

我正在尝试使用优秀的 AWS SDK amazonka在使用同样出色的 Web 框架构建的 API 的后端部分 yesod ,但是我很难让这两个库的依赖项一起工作。

我开始了脚手架 yesod 项目

stack new my-project yesod-mongo

它用最新版本的 yesod (1.6.0) 填充了我的 cabal 文件。天真地将依赖项 amazonka-coreamazonka-ssm (例如)添加到我的 cabal 文件中会返回

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for my-project-0.0.0:
amazonka-core must match -any, but the stack configuration has no specified version
(latest matching version is 1.5.0)
amazonka-ssm must match -any, but the stack configuration has no specified version
(latest matching version is 1.5.0)
needed since my-project is a build target.

按照建议,我尝试将 amazonka-core-1.5.0amazonka-ssm-1.5.0 添加到 extra- 下的 stack.yaml 文件中deps,但这不起作用:

Warning: WARNING: /home/ubuntu/my-project/my-project.cabal was modified manually.
Ignoring package.yaml in favor of cabal file. If you want to use package.yaml
instead of the cabal file, then please delete the cabal file.

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for amazonka-core-1.5.0:
conduit-1.3.0.2 from stack configuration does not match >=1.1 && <1.3 (latest
matching version is 1.2.13.1)
needed due to my-project-0.0.0 -> amazonka-core-1.5.0

经过一番挖掘,似乎 yesod 模板构建的快照是 lts-11.6,但 amazonka 库包含的最新快照是 lts-10.9。因此,我尝试从 yesod-mongo 模板再次构建项目,但这次指定了较旧的快照:

ubuntu:~$ stack new my-project yesod-mongo --resolver lts-10.9
Downloading template "yesod-mongo" to create project "my-project" in my-project/ ...
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- my-project/

Selected resolver: lts-10.9
Resolver 'lts-10.9' does not have all the packages to match your requirements.
classy-prelude version 1.3.1 found
- my-project requires ==1.4.*
classy-prelude-conduit version 1.3.1 found
- my-project requires ==1.4.*
classy-prelude-yesod version 1.3.1 found
- my-project requires ==1.4.*
http-conduit version 2.2.4 found
- my-project requires ==2.3.*
persistent version 2.7.1 found
- my-project requires ==2.8.*
persistent-mongoDB version 2.6.0 found
- my-project requires ==2.8.*
yesod version 1.4.5 found
- my-project requires ==1.6.*
yesod-auth version 1.4.21 found
- my-project requires ==1.6.*
yesod-core version 1.4.37.3 found
- my-project requires ==1.6.*
yesod-form version 1.4.16 found
- my-project requires ==1.6.*
yesod-static version 1.5.3.1 found
- my-project requires ==1.6.*
Using package flags:
- my-project: dev = False, library-only = False

现在我很茫然,而且有点沮丧。看起来模板可能忽略了快照规范。所以,我的问题是:

有没有办法从使用特定快照来填充 cabal 和 stack.yaml 文件的模板构建脚手架站点?我还能做些什么来让它发挥作用吗?

如果有帮助,我们很乐意提供更多信息。

编辑:我还尝试降低上面代码片段中软件包的版本,虽然这解决了构建依赖项的问题,但现在脚手架站点无法编译(大概是因为事情已经发生了)以有意义的方式从 yesod-1.4.5 更改为 yesod-1.6.0)。

最佳答案

不幸的是,您无法使用 Commercial Haskell's截至目前,使用 yesod 和 amazonka 堆栈模板。原因是:

让它工作的唯一方法是切换回旧版本的堆栈模板(那些实际上与堆栈解析器 10.9 一起使用的模板),然后使用它来创建一个新项目。幸运的是,Stack 支持自定义堆栈模板:

$ stack new my-project https://raw.githubusercontent.com/github-user-id/stack-templates/master/my-template.hsfiles

关于haskell - 在 Haskell Stack 项目中构建 yesod/amazonka 依赖项时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50079324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com