yesodubuntu-13.10cabal-dev

Setting up Yesod on Ubuntu 13.10


After following the instructions on the QuickStart, I'm seeing some errors in Yesod when bringing up a webpage. The errors end in:

...

cannot satisfy -package-id wai-extra-1.3.4.6-62543d69d10941dae1d9b206c3eb3067:

wai-extra-1.3.4.6-62543d69d10941dae1d9b206c3eb3067 is unusable due to missing or recursive dependencies:
  blaze-builder-conduit-1.0.0-1053545317cd68e3d51439dd9a0e622d zlib-conduit-1.0.0-b51dc7daf506ea4c5ecd031c5101d96a
(use -v for more information)

Build failure, pausing...

Hopefully related, the referenced tutorial has me run

cabal-dev install

on a fresh Yesod project, however that also gives me errors:

...

[1 of 1] Compiling Control.Monad.Logger ( Control/Monad/Logger.hs, dist/build/Control/Monad/Logger.o )

Control/Monad/Logger.hs:63:39: Module System.Log.FastLogger' does not exportpushLogStr'

Control/Monad/Logger.hs:63:72: Module System.Log.FastLogger' does not exportLoggerSet'

Control/Monad/Logger.hs:63:83: Module System.Log.FastLogger' does not exportnewLoggerSet'

Control/Monad/Logger.hs:63:97: Module System.Log.FastLogger' does not exportdefaultBufSize' Failed to install monad-logger-0.3.3.0

...

On this later set of errors, I came across a page suggesting the issue has been fixed (SO won't let me post more than 2 links, but Google the error and it comes right up).

Any ideas?

Thanks in advance!


Solution

  • I'd suggest using cabal sandbox for each Yesod project, rather than installing the Yesod platform as part of your system libraries. Think of a cabal sandbox as a localized collection of Haskell packages in a single project, so you could have different versions of a package, say Data.Text, in 2 different cabal sandboxes. Using cabal sandbox takes longer time for compilation but it makes things simpler for dependency resolution (read more here: (read more here: http://coldwa.st/e/blog/2013-08-20-Cabal-sandbox.html). cabal sandbox requires a cabal version of at least 1.18 if I'm not mistaken.

    Alright, enough of the talk. Let's get started.

    To get the latest cabal, it's easier if you have cabal installed through a package manager, even if the package manager installs a cabal without cabal sandbox. Since you are on Ubuntu, just:

    sudo apt-get install cabal
    

    Once you have some version of cabal installed, run:

    cabal sandbox
    

    If you see something along the lines of this:

    cabal: Please specify a subcommand (see 'help sandbox')
    

    Then congratulations, the version of cabal that you have supports cabal sandbox, just move on Once you have a Cabal with cabal sandbox section of the answer.

    If instead you see something like:

    cabal: unrecognised command: sandbox (try --help)
    

    Then you will need a more modern version of cabal. Simply clone the cabal repository on github:

    git clone https://github.com/haskell/cabal.git
    

    Go to the directory, and checkout the branch Cabal-v1.18.1.2, like so:

    git checkout Cabal-v1.18.1.2
    

    Then execute:

    cabal install Cabal/ cabal-install/
    

    This should install cabal in the $HOME/.cabal/bin folder. Be sure to prepend $HOME/.cabal/bin to your PATH environment variable, before the folder where the system's cabal is located.

    Once you have a Cabal with cabal sandbox

    Based on what I read from the Yesod quick start guide, you will want to install the yesod-bin package. It's hackage page is here. Basically, yesod-bin provides you with a yesod binary that allows you to initialize a scaffolded site. The latest version of yesod-bin is 1.2.5.6, and that's what we're going to install.

    Create a directory named yesod-bin:

    mkdir yesod-bin
    

    Go into that directory, and set up a cabal sandbox in that it, like so:

    cabal sandbox init
    

    Fetch the latest package list from hackage using:

    cabal update
    

    Now, we are going to install the latest version of yesod-bin, 1.2.5.6, in a cabal sandbox. However, yesod-bin has a dependency on the mmorph package, which defaults to install version 1.01, and trying to install mmorph-1.01 will result in an error message like the following:

    src/Control/Monad/Morph.hs:76:8:
        Could not find module `Control.Applicative.Backwards'
        Use -v to see a list of the files searched for.
    Failed to install mmorph-1.0.1
    cabal: Error: some packages failed to install:
    mmorph-1.0.1 failed during the building phase. The exception was:
    ExitFailure 1
    

    and installing yesod-bin without specifiy the mmorph package version defaults to installing mmorph-1.0.1, resulting in the following error:

    cabal: Error: some packages failed to install:
    base64-conduit-1.0.0 depends on mmorph-1.0.1 which failed to install.
    blaze-builder-conduit-1.0.0 depends on mmorph-1.0.1 which failed to install.
    conduit-1.0.10 depends on mmorph-1.0.1 which failed to install.
    http-client-conduit-0.2.0.1 depends on mmorph-1.0.1 which failed to install.
    http-conduit-2.0.0.3 depends on mmorph-1.0.1 which failed to install.
    http-reverse-proxy-0.3.0 depends on mmorph-1.0.1 which failed to install.
    mmorph-1.0.1 failed during the building phase. The exception was:
    ExitFailure 1
    network-conduit-1.0.1 depends on mmorph-1.0.1 which failed to install.
    project-template-0.1.3.2 depends on mmorph-1.0.1 which failed to install.
    resourcet-0.4.10 depends on mmorph-1.0.1 which failed to install.
    wai-2.0.0 depends on mmorph-1.0.1 which failed to install.
    wai-logger-2.1.1 depends on mmorph-1.0.1 which failed to install.
    warp-2.0.2 depends on mmorph-1.0.1 which failed to install.
    yaml-0.8.5.3 depends on mmorph-1.0.1 which failed to install.
    yesod-bin-1.2.5.6 depends on mmorph-1.0.1 which failed to install.
    

    which seems to be related to these 2 issues in the mmorph github repo:

    However, mmorph version 1.0.0 works fine. As such, we will have to specify the version of mmorph to be 1.0.0 when we install yesod-bin, like this:

    cabal install mmorph-1.0.0 yesod-bin-1.2.5.6
    

    This will take quite some time. cabal sandbox creates a directory named .cabal-sandbox inside the yesod-bin directory, and the yesod binary (along with several other binaries from the yesod-bin package) can be found in the .cabal-sandbox/bin folder. Simply add that folder into your PATH, and you should be able to do the yesod init and yesod devel as seen at the end of the quick start.