【问题标题】:Trouble building yesod/amazonka dependencies in a Haskell Stack project在 Haskell Stack 项目中构建 yesod/amazonka 依赖项时遇到问题
【发布时间】:2018-04-28 17:35:55
【问题描述】:

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

我开始使用脚手架 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-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 文件?我还能做些什么来让它工作吗?

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

编辑: 我还尝试降低上述 sn-p 中包的版本,虽然这解决了构建依赖项的问题,但现在脚手架站点无法编译(可能是因为从 yesod-1.4.5 到 yesod-1.6.0,事情发生了有意义的变化)。

【问题讨论】:

    标签: haskell yesod haskell-stack


    【解决方案1】:

    很遗憾,到目前为止,您无法将 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多