在 Haskell Stack 项目中构建 yesod/amazonka 依赖项时遇到问题
Trouble building yesod/amazonka dependencies in a Haskell Stack project
我正在尝试使用出色的 AWS SDK amazonka in the backend portion of an API built using the equally excellent web framework yesod,但我很难让这两个库的依赖项协同工作。
我用
开始了脚手架 yesod 项目
stack new my-project yesod-mongo
用最新版本的 yesod (1.6.0) 填充了我的 cabal 文件。天真地将依赖项 amazonka-core
和 amazonka-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.0
和 amazonka-ssm-1.5.0
添加到 extra-deps
下的 stack.yaml 文件中,但这不起作用:
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 一起使用。原因是:
- There was a recent conduit rewrite in version 1.3
- Some breaking changes were introduced in recent Yesod 1.6 which depends on conduit >= 1.3
- Amazonka doesn't work with recent version of conduit
让它工作的唯一方法是切换回旧版本的堆栈模板(那些实际上与堆栈解析器 10.9 一起工作的模板),然后使用它来创建一个新项目。幸运的是,Stack 支持自定义堆栈模板:
$ stack new my-project https://raw.githubusercontent.com/github-user-id/stack-templates/master/my-template.hsfiles
我正在尝试使用出色的 AWS SDK amazonka in the backend portion of an API built using the equally excellent web framework yesod,但我很难让这两个库的依赖项协同工作。
我用
开始了脚手架 yesod 项目stack new my-project yesod-mongo
用最新版本的 yesod (1.6.0) 填充了我的 cabal 文件。天真地将依赖项 amazonka-core
和 amazonka-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.0
和 amazonka-ssm-1.5.0
添加到 extra-deps
下的 stack.yaml 文件中,但这不起作用:
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 一起使用。原因是:
- There was a recent conduit rewrite in version 1.3
- Some breaking changes were introduced in recent Yesod 1.6 which depends on conduit >= 1.3
- Amazonka doesn't work with recent version of conduit
让它工作的唯一方法是切换回旧版本的堆栈模板(那些实际上与堆栈解析器 10.9 一起工作的模板),然后使用它来创建一个新项目。幸运的是,Stack 支持自定义堆栈模板:
$ stack new my-project https://raw.githubusercontent.com/github-user-id/stack-templates/master/my-template.hsfiles