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.