takafumi blog

日々の勉強メモ

【Haskell】 stack で ghc-modがインストールできない

環境   ghc 7.10.2 CentOS7.0

Haskellのパッケージ管理をstackにしてみた。

順調にインストールはし、Yesodもcabal hellせずナイスと思ったら、ghc-modがインストールできない。

$ stack install ghc-mod
While constructing the BuildPlan the following exceptions were encountered:

--  While attempting to add dependency,
    Could not find package cabal-helper in known packages

--  Failure when adding dependencies:
      cabal-helper: needed (==0.6.* && >=0.6.0.0), not present in build plan (latest is 0.6.1.0)
    needed for package: ghc-mod-5.4.0.0

Recommended action: try adding the following to your extra-deps in /home/User/MyProject/stack.yaml
- cabal-helper-0.6.1.0

You may also want to try the 'stack solver' command

stackなのに依存性の問題?
cabal-helperが必要なのか?
とおもってやってみてもエラー。

$ stack install cabal-helper
Couldn't find executable cabal-helper-wrapper in directory /home/User/MyProject/.stack-work/install/x86_64
-linux/lts-3.10/7.10.2/bin/

$ # stack install cabal-helper-wrapper
Using resolver: lts-3.10 from implicit global project's config file: /root/.stack/global-project/stack.yaml
The following target packages were not found: cabal-helper-wrapper

で、いろいろ調べてみたところ、以下のissueを発見。 github.com

・・・よくわからないけど無理やり読み進めて、以下の様にすればよい?

$ stack build ghc-mod cabal-helper

ローカルプロジェクト上に配置もできるが、PATH通すのが面倒だったので、グローバルプロジェクトに構築。
とりあえず動いた。


buildinstallの違いが良くわからなかったのでこれも調べてみた。

$ stack --help
  build                    Build the project(s) in this directory/configuration
  install                  Shortcut for 'build --copy-bins'

つまりstack installstack build --copy-binsと同じ。

$ stack build --help
  --copy-bins              Enable copying binaries to the local-bin-path (see
                           'stack path') (--no-copy-bins to disable)

・・・つまり--copy-bins無しだとプロジェクトで依存性が発生するバイナリでもコピーするって事か?

今一よくわからないが、ヘルプ見ても、ググッてもよくわからなかったので、後は使ってみて問題でたら考えよう。