agrafix / Spock

Another Haskell web framework for rapid development
https://www.spock.li
679 stars 56 forks source link

stm-containers versions 1.* cause Spock builds to fail. #149

Closed flounders closed 3 years ago

flounders commented 5 years ago

I was trying to use Spock with cabal new-build and it kept failing with this message:

src/Web/Spock/Internal/SessionVault.hs:17:1: error:
    Could not find module ‘STMContainers.Map’
    Perhaps you meant StmContainers.Map (from stm-containers-1)
    Use -v to see a list of the files searched for.
   |
17 | import qualified STMContainers.Map as STMMap
   |

After looking at the documentation for stm-containers on Hackage I noticed that the case change on the modules happened with the 1.0 release. On default stack settings it is still building fine because lts-12.12 uses stm-containers 0.2.16. I've created a pull request (https://github.com/agrafix/Spock/pull/148) to restrict the upper bounds for stm-containers to < 0.3, and that lets it build properly.

code5hot commented 5 years ago

Hi flounders, can you recommend how I can easily make use of your fix in my sandbox?

Note when I install with --constraint='stm-containers<0.3' I get unresolved dependencies. I think a fix for the cabal graph should leave installation working for all recent cabal installs and the majority of older ones.

flounders commented 5 years ago

@code5hot Sadly I deleted the project I used to build and fix the problem, so it took me a little bit to recreate my steps. I don't know if this will work with sandboxes. I've been using the new-build command where possible and stack otherwise. My pull request got merged today, so you should be able to clone this repository and use the master branch. You will want your copy of the repository to be in your project's top level directory. Then edit cabal.project (should be in your project's top level directory) to have packages: Spock/Spock/Spock.cabal. Then try building. If the sandbox build does not work, try cabal new-build.

flounders commented 5 years ago

@agrafix I figured the version upper bounds would be the easiest fix for now. If you want I can start looking at what it would take to make it 1.* compatible.

code5hot commented 5 years ago

I was able to install it after unregistering various other packages and constraining both spock and stm-containers... an older spock tried to install.

On Tue, 30 Oct 2018, 19:36 Steven Michael Williams, < notifications@github.com> wrote:

@agrafix https://github.com/agrafix I figured the version upper bounds would be the easiest fix for now. If you want I can start looking at what it would take to make it 1.* compatible.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/agrafix/Spock/issues/149#issuecomment-434417209, or mute the thread https://github.com/notifications/unsubscribe-auth/AfPM5Y09FSpPeNHvwXIsDFswgHtHMASiks5uqJw8gaJpZM4XW4sP .

benjaminweb commented 5 years ago

https://github.com/agrafix/Spock/pull/152 is a working fork with recent stm-containers.

ImreMD commented 5 years ago

Same problem I manage to correct the module' name in a local version of the package additionally you will need to replace STMMap.stream by STMMap.listT in SessionVault.hs - then all work fine for me (stack + windows 10)

benjaminweb commented 5 years ago

@ImreMD please confirm that you still have the issue when installing 6492690090b545544c06382dea3e5df7915efbd5.

aaronang commented 5 years ago

I am new to Haskell and tried following the Spock - Getting Started article. I am running into the same problem.

Reproducible steps

  1. Create new project using Stack:

    $ stack new Spock-example
    $ cd Spock-example
  2. Change executable build-depends defined in Spock-example.cabal to include Spock >=0.11, mtl, and text:

    executable Spock-example-exe
    main-is: Main.hs
    other-modules:
       Paths_hello_spock
    hs-source-dirs:
       app
    ghc-options: -threaded -rtsopts -with-rtsopts=-N
    build-depends:
       base >=4.7 && <5
     , hello-spock
     , Spock >=0.11
     , mtl
     , text
    default-language: Haskell2010
  3. Change extra-deps in stack.yaml to include Spock, Spock-core, reroute:

    extra-deps:
    - Spock-0.13.0.0
    - Spock-core-0.13.0.0
    - reroute-0.5.0.0
  4. Build:

    $ stack build --fast --pedantic
    
    Warning: /Users/aang/Code/Spock-example/Spock-example.cabal was modified manually.
            Ignoring /Users/aang/Code/Spock-example/package.yaml in favor of the cabal
            file. If you want to use the package.yaml file 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 Spock-0.13.0.0:
       stm-containers must match >=0.2, but the stack configuration has no specified
                      version  (latest matching version is 1.1.0.2)
    needed due to Spock-example-0.1.0.0 -> Spock-0.13.0.0
    
    Some different approaches to resolving this:
    
     * Consider trying 'stack solver', which uses the cabal-install solver to attempt
       to find some working build configuration. This can be convenient when dealing
       with many complicated constraint errors, but results may be unpredictable.
    
     * Recommended action: try adding the following to your extra-deps
       in /Users/aang/Code/Spock-example/stack.yaml:
    
    stm-containers-1.1.0.2@sha256:68f11870da794c570245f03fff98bc06251443780315324a7f2b01a07a1ebe91
    
    Plan construction failed.
  5. Add the recommended dependencies to extra-deps in stack.yaml:

    extra-deps:
    - Spock-0.13.0.0
    - Spock-core-0.13.0.0
    - reroute-0.5.0.0
    - stm-containers-1.1.0.2@sha256:68f11870da794c570245f03fff98bc06251443780315324a7f2b01a07a1ebe91
    - focus-1.0.1.3@sha256:adfb0c747394e5dc5d4839167b95f6f9673162b68eb7e7cf11ba39ddf648f8e8
    - stm-hamt-1.2.0.2@sha256:18126db7bf2d9c967a6020c677b3005dd957a4c39d69aeaea3c29c90de8f6124
    - primitive-extras-0.7.1@sha256:23905c57089418b1a2d324cfee3e81bbd5a344a0fa56a827867b2dce275fdb5e
  6. Build again:

    $ stack build --fast --pedantic
    
    Warning: /Users/aang/Code/Spock-example/Spock-example.cabal was modified manually. Ignoring /Users/aang/Code/Spock-example/package.yaml in favor of the cabal file. If you want to use the package.yaml file
            instead of the cabal file, then please delete the cabal file.
    Spock-0.13.0.0: configure
    Spock-0.13.0.0: build
    Progress 1/2
    
    --  While building package Spock-0.13.0.0 using:
         /Users/aang/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
       Process exited with code: ExitFailure 1
       Logs have been written to: /Users/aang/Code/Spock-example/.stack-work/logs/Spock-0.13.0.0.log
    
       Configuring Spock-0.13.0.0...
       Preprocessing library for Spock-0.13.0.0..
       Building library for Spock-0.13.0.0..
       [1 of 7] Compiling Web.Spock.Internal.Types ( src/Web/Spock/Internal/Types.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Web/Spock/Internal/Types.o )
       [2 of 7] Compiling Web.Spock.Internal.SessionVault ( src/Web/Spock/Internal/SessionVault.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Web/Spock/Internal/SessionVault.o )
    
       /private/var/folders/pq/s9vv6vx97fs3ml8y619n_7gwtz57gc/T/stack-d64fb9a064356bbe/Spock-0.13.0.0/src/Web/Spock/Internal/SessionVault.hs:17:1: error:
           Could not find module ‘STMContainers.Map’
           Perhaps you meant StmContainers.Map (from stm-containers-1.1.0.2)
           Use -v to see a list of the files searched for.
          |
       17 | import qualified STMContainers.Map as STMMap
          | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Workaround

Change extra-deps in stack.yaml to include stm-containers-0.2.16:

extra-deps:
- Spock-0.13.0.0
- Spock-core-0.13.0.0
- reroute-0.5.0.0
- stm-containers-0.2.16
- focus-0.1.5.2

Building this configuration works.

Comments

It seems that @benjaminweb's patch should work with a more recent version of stm-containers but there hasn't been an official release of Spock 0.13.0.2 to Hackage.

I have no clue what I am doing since I recently started to learn Haskell.

voidus commented 5 years ago

I got things working by switching to a lts-12 resolver, which has an old, stm-containers-compatible version of focus. It also contains Spock, so I just needed to add Spock >= 0.13.0 && < 0.14 to my package.yml.

I'm guessing the reason it's not included in lts-13 is this issue. Maybe we can fix that by pushing out a new release?

In the meantime, the documentation should probably point people to the old resolver with a short explanation.

Zialus commented 5 years ago

No updates on a new release tag on hackage?

benjaminweb commented 5 years ago

@agrafix What needs to be done for that release tag?

rnhmjoj commented 5 years ago

Is the project still alive? Spock has been broken in NixOS for almost two years. I'm only using it in a toy project but it's pretty annoying that I have to override the package and bunch of dependencies just to make it compile.

Zialus commented 4 years ago

@agrafix is the project dead?

rnhmjoj commented 4 years ago

Effectively it is. It's really a shame that both Spock and Scotty development stopped. I switched to Servant, I'm happy with it, but I enjoyed the semplicity of Spock.

agrafix commented 3 years ago

This is fixed now, sorry for the delay :)