今のバージョンでYesodアプリを動かすまで

なんかうまく動かなくなってたので、メモ。

まずは、Haskell Platform を確認。
気がついたら64bitが入っていた。
多分 2012.4.0.0 にするときに誤って入れたらしい。
一旦今の Haskell 環境を消して、

$ sudo /Library/Haskell/bin/uninstall-hs --remove thru 7.4.2
$ rm -rf ~/.cabal/ ~/.ghc/ ~/cabal-dev/
$ rm -rf ~/Library/Haskell/
$ sudo rm -rf /Library/Haskell/
$ sudo rm -rf /Library/Frameworks/GHC.framework

で、32bitをいんすこした。


次。cabal-dev を入れる。

$ cd ~/Downloads
$ git clone git@github.com:creswick/cabal-dev.git
$ cd cabal-dev
$ cabal install


次。yesod-platform を入れる。

$ cd
$ cabal-dev install yesod-platform


次。PATHを当てる。
自分の場合は .bashrc を弄る。
(そのうち zsh に移ろうと言い続けて何年だろう・・・)

export PATH=〜:$HOME/cabal-dev/bin:$HOME/Library/Haskell/bin:〜:$PATH


ここまでで yesod コマンドが使えるはずなので確認。

$ yesod version
yesod-core version:1.1.6.1
yesod version:1.1.4.1


適当に yesod アプリを作ってみる。

$ yesod init
... (適当に hoge っていうプロジェクトを作ってみた)


で、ビルド。

$ cd hoge
$ cabal-dev install
...
Preprocessing library http-conduit-1.8.5.1...
[ 1 of 11] Compiling Network.HTTP.Conduit.Util ( Network/HTTP/Conduit/Util.hs, dist/build/Network/HTTP/Conduit/Util.o )
[ 2 of 11] Compiling Network.HTTP.Conduit.Chunk ( Network/HTTP/Conduit/Chunk.hs, dist/build/Network/HTTP/Conduit/Chunk.o )
[ 3 of 11] Compiling Network.HTTP.Conduit.Types ( Network/HTTP/Conduit/Types.hs, dist/build/Network/HTTP/Conduit/Types.o )
[ 4 of 11] Compiling Network.HTTP.Conduit.Parser ( Network/HTTP/Conduit/Parser.hs, dist/build/Network/HTTP/Conduit/Parser.o )
[ 5 of 11] Compiling Network.HTTP.Conduit.ConnInfo ( Network/HTTP/Conduit/ConnInfo.hs, dist/build/Network/HTTP/Conduit/ConnInfo.o )
***/cabal-dev//lib/Crypto/Random/AESCtr.hi
Declaration for $wmakeParams:
  Bad interface file: ***/cabal-dev//lib/Crypto/Cipher/AES.hi
      Something is amiss; requested module  cipher-aes-0.1.5:Crypto.Cipher.AES differs from name found in the interface file cryptocipher-0.3.7:Crypto.Cipher.AES
Cannot continue after interface file error
Failed to install http-conduit-1.8.5.1
Configuring classy-prelude-conduit-0.4.2...
...
cabal: Error: some packages failed to install:
hoge-0.0.0 depends on http-conduit-1.8.5.1 which failed to install.
authenticate-1.3.2 depends on http-conduit-1.8.5.1 which failed to install.
clientsession-0.8.0.1 failed during the building phase. The exception was:
ExitFailure 1
http-conduit-1.8.5.1 failed during the building phase. The exception was:
ExitFailure 1
http-reverse-proxy-0.1.0.7 depends on http-conduit-1.8.5.1 which failed to install.
yesod-1.1.7 depends on http-conduit-1.8.5.1 which failed to install.
yesod-auth-1.1.3 depends on http-conduit-1.8.5.1 which failed to install.
yesod-core-1.1.6.1 depends on clientsession-0.8.0.1 which failed to install.
yesod-default-1.1.3 depends on clientsession-0.8.0.1 which failed to install.
yesod-form-1.2.0.2 depends on clientsession-0.8.0.1 which failed to install.
yesod-json-1.1.2 depends on clientsession-0.8.0.1 which failed to install.
yesod-persistent-1.1.0.1 depends on clientsession-0.8.0.1 which failed to install.
yesod-static-1.1.1.1 depends on clientsession-0.8.0.1 which failed to install.


どうも http-conduit のビルドでこけている。
cipher-aes-0.1.5 の Crypto.Cipher.AES と、cryptocipher-0.3.7 の Crypto.Cipher.AES があって、
モジュール名が同じじゃねーか!的なエラー。

http-conduit は cprng-aes に依存していて、
cprng-aes はデフォルトでは cipher-aes に依存するようになっている。
また、http-conduit は tls に依存していて、
tls は cryptocipher に依存している。

それとは別に、yesod init によって作られたプロジェクトは
clientsession に依存するようになっていて、
clientsession は cryptocipher に依存している。

cprng-aes の設定を見てみると、Flag によって cipher-aes ではなく cryptocipher に依存するようにできるらしい。


ということで、cprng-aes だけ設定を変えて先に入れるようにして
再度ビルドしてみる。

$ rm -rf cabal-dev/ 
$ cabal-dev install -f -fastaes cprng-aes 
$ cabal-dev install 

無事ビルドできた。


さて 動かしてみる。

$ yesod --dev devel
Yesod devel server. Press ENTER to quit
Resolving dependencies...
Configuring hoge-0.0.0...
Rebuilding application... (using cabal-dev)
Building hoge-0.0.0...
Preprocessing library hoge-0.0.0...
In-place registering hoge-0.0.0...
ERROR: Could not read BuildInfo file: dist/setup-config
Make sure that cabal-install has been compiled with the same GHC version as yesod.
and that the Cabal library used by GHC is the same version
cannot parse contents
yesod: ExitFailure 1

・・・あれ?

$ dist/build/hoge/hoge Development
Migrating: CREATE TABLE "user"("id" INTEGER PRIMARY KEY,"ident" VARCHAR NOT NULL,"password" VARCHAR NULL,CONSTRAINT "unique_user" UNIQUE ("ident"))
Migrating: CREATE TABLE "email"("id" INTEGER PRIMARY KEY,"email" VARCHAR NOT NULL,"user" INTEGER NULL REFERENCES "user","verkey" VARCHAR NULL,CONSTRAINT "unique_email" UNIQUE ("email"))
127.0.0.1 - - [23/Dec/2012:16:43:43 +0900] "GET / HTTP/1.1" 200 - "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.101 Safari/537.11"
^C

こっちは動く。


ま、とにかく動かせるようになったので、今回はここまで。