简体   繁体   中英

Trouble building yesod/amazonka dependencies in a Haskell Stack project

I'm trying to use the excellent AWS SDK amazonka in the backend portion of an API built using the equally excellent web framework yesod , but I am having great difficulty getting the dependencies for these two libraries to work together.

I started the scaffolded yesod project with

stack new my-project yesod-mongo

which populated my cabal file with the most recent version of yesod (1.6.0). Naively adding the dependencies amazonka-core and amazonka-ssm (for example) to my cabal file comes back with

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.

As suggested, I tried adding amazonka-core-1.5.0 and amazonka-ssm-1.5.0 to my stack.yaml file under extra-deps , but this doesn't work:

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

After a bit of digging, it seems that the snapshot that the yesod template was built off of is lts-11.6, but the most recent snapshot that the amazonka library is included in is lts-10.9. So, I tried building the project again from the yesod-mongo template, but this time specifying an older snapshot:

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

Now I am at a loss and more than a little frustrated. It seems like perhaps the template is ignoring the snapshot specification. So, my question:

Is there a way to build the scaffolded site from a template that uses a specific snapshot to fill in the cabal and stack.yaml files? Is there anything else I can do to get this to work?

Happy to provide more information if it's helpful.

Edit: I also tried bumping down the versions of the packages in the above snippet, and while this solves the issue of building dependencies, now the scaffolded site doesn't compile (presumably because things have changed in a meaningful way from yesod-1.4.5 to yesod-1.6.0).

Unfortunately you can't use Commercial Haskell's stack templates with yesod and amazonka as of now. The reasons being:

The only way for you to get it working is switching back to old version of stack templates (those templates which actually worked with stackage resolver 10.9) and then using that to create a new project. Fortunately, Stack supports custom stack templates:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM