一歩前進

プログラミングに関する雑多なメモ

ghc-mod-3.1.5 depends on haskell-src-exts-1.14.0 which failed to install.

cabalからghc-modを入れようとしたら以下のようなエラーに遭遇しました。

cabal: Error: some packages failed to install:
ghc-mod-3.1.5 depends on haskell-src-exts-1.14.0 which failed to install.
haskell-src-exts-1.14.0 failed during the configure step. The exception was:
ExitFailure 1
hlint-1.8.57 depends on haskell-src-exts-1.14.0 which failed to install.

どうやらhaskell-src-extsというパッケージが入っていないことが原因らしい。 依存関係がうまく解決できていないようなので、手動で依存パッケージを入れていきます。 まずhaskell-src-extsをインストールします。

$ cabal install haskell-src-exts
...(中略)
setup: The program happy version >=1.17 is required but the version of
/Users/succzero/.cabal/bin/happy could not be determined.
Failed to install haskell-src-exts-1.14.0
cabal: Error: some packages failed to install:
haskell-src-exts-1.14.0 failed during the configure step. The exception was:
ExitFailure 1

エラーになりました。どうやらHaskellパーサーのhappyが必要なようです。ですが、このパッケージはMacPorts経由で入れていたのでした(パッケージ名はhs-happy)。

$ which happy
/opt/local/bin/happy

しかし、エラーメッセージをよくよく見ると、/Users/succzero/.cabal/bin/happy could not be determined.と出ており、.cabalにインストールされていないといけないようです。 というわけで、cabalからインストールします。

$ cabal install happy

インストールできたので、確認します。

$ which happy
/Users/succzero/.cabal/bin/happy

happyの位置が.cabal側を向くようになっているので意識しておいたほうがいいですね。むしろ、Haskell関係のパッケージはcabalに集中させたほうがいいかもしれません。 ちなみに、cabalからインストールしたhappyのバージョンの方が最新でした。

$ ~/.cabal/bin/happy --version
Happy Version 1.19.3 Copyright (c) 1993-1996 Andy Gill, Simon Marlow (c) 1997-2005 Simon Marlow
$ /opt/local/bin/happy --version
Happy Version 1.18.10 Copyright (c) 1993-1996 Andy Gill, Simon Marlow (c) 1997-2005 Simon Marlow

さて、気を取り直してもう一度。

$ cabal install haskell-src-exts
...
Registering haskell-src-exts-1.14.0...
Installed haskell-src-exts-1.14.0

今度はインストール出来ました。 最初のエラーメッセージでhlint-1.8.57 depends on haskell-src-exts-1.14.0 which failed to installと表示されていたので、次にhlintもインストールしておきます。

実はここで間違えて、hlintではなくhintパッケージを入れてしまいました。

$ cabal install hint

どうやらHaskellインタプリタのようです。 http://projects.haskell.org/hint/ インタプリタなのでHaskellソースコードを解釈できるわけですね。実行時になんらかのHaskellソースファイルをロードして、指定された関数を解釈させてやれば、動的なモジュールロードとかリフレクションみたいな使い方が出来そうです。これは面白そう!

話を戻して、hlintをインストールします。

$ cabal install hlint
...
Registering hlint-1.8.57...
Installed hlint-1.8.57

ここでようやく本命のghc-modをインストールします。

$ cabal install ghc-mod
...
Registering ghc-mod-3.1.5...
Installed ghc-mod-3.1.5
$ which ghc-mod
/Users/succzero/.cabal/bin/ghc-mod

無事、ghc-modをインストールできました。