IT練習ノート

IT関連で調べたこと(実際は嵌ったこと)を書いています。

stack自体のupdateの作業ログ (2018年01月)

stack buildをすると、cabalのバージョン不整合のエラーがでました。

$ stack build
Unable to parse cabal file: FromString "This package requires at least Cabal version 2.0" Nothing

確認すると不整合はなさそうです。

$ cabal --version
cabal-install version 2.0.0.1
compiled using version 2.0.1.1 of the Cabal library

stackoverflowに情報がありました。stack自体のバージョンが1.5以上である必要があるとのこと。

stackoverflow.com

バージョンを確認すると、1.1.2でした。

$ stack --version
Version 1.1.2, Git revision cebe10e845fed4420b6224d97dcabf20477bbd4b (3646 commits) x86_64 hpack-0.14.0

本家サイトでアップデート方法を確認します。

Install/upgrade - The Haskell Tool Stack

それに従ってコマンドを入力するとエラーとなります。

$ curl -sSL https://get.haskellstack.org/ | sh
Stack Version 1.1.2 already appears to be installed at:
  /usr/local/bin/stack
Use 'stack upgrade' or your OS's package manager to upgrade,
or pass '-f' to this script to over-write the existing binary, e.g.:
  curl -sSL https://get.haskellstack.org/ | sh -s - -f

エラーメッセージに従って、コマンドを入力すると最新版のダウンロードとインストールが始まりました。

$ stack upgrade
remote: Counting objects: 13480, done.
remote: Compressing objects: 100% (11071/11071), done.
remote: Total 13480 (delta 3490), reused 10929 (delta 2132), pack-reused 0
Receiving objects: 100% (13480/13480), 3.87 MiB | 655.00 KiB/s, done.
Resolving deltas: 100% (3490/3490), completed with 1189 local objects.
From https://github.com/commercialhaskell/all-cabal-hashes
 + 89bc508...936cc04 hackage    -> origin/hackage  (forced update)
 - [tag update]      current-hackage -> current-hackage
Fetched package index.
Populated index cache.
stack-1.6.3: download
Downloaded lts-9.14 build plan.

途中でワーニングが出ました。

Right Nothing
Did not find .cabal file for Agda-2.5.3 with Git SHA of 82d11286c281716649dc25e0820b3e25214af971
Right Nothing
WARNING: Ignoring unknown field "custom-setup" in package description
WARNING: Ignoring unknown field "custom-setup" in package description
No packages found in snapshot which provide a "hsc2hs" executable, which is a build-tool dependency of "stack"
No packages found in snapshot which provide a "hsc2hs" executable, which is a build-tool dependency of "stack"
Missing build-tools may be caused by dependencies of the build-tool being overridden by extra-deps.
This should be fixed soon - see this issue https://github.com/commercialhaskell/stack/issues/595

stack自体のコンパイルが実行されます。ここが時間がかかりました。

Configuring stack-1.6.3...
stack-1.6.3: build
Preprocessing library stack-1.6.3...
[  1 of 126] Compiling System.Terminal  ( .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/System/Terminal.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/System/Terminal.o )
[  2 of 126] Compiling Stack.Prelude    ( src/Stack/Prelude.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Stack/Prelude.o )
[  3 of 126] Compiling Stack.StaticBytes ( src/Stack/StaticBytes.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Stack/StaticBytes.o )

最後にパスの問題でワーニングが出てしまいました。

[1 of 2] Compiling Paths_stack      ( .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/autogen/Paths_stack.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/stack/stack-tmp/Paths_stack.o )
[2 of 2] Compiling Main             ( src/main/Main.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/stack/stack-tmp/Main.o )
Linking .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/stack/stack ...
stack-1.6.3: copy/register
Installing library in
/private/var/folders/hw/p4bp49hd7v9_1j60sjvmhqnr0000gn/T/stack-upgrade57634/stack-1.6.3/.stack-work/install/x86_64-osx/lts-9.14/8.0.2/lib/x86_64-osx-ghc-8.0.2/stack-1.6.3-6ncwAxsY27uGm82EJKrhWo
Installing executable(s) in
/private/var/folders/hw/p4bp49hd7v9_1j60sjvmhqnr0000gn/T/stack-upgrade57634/stack-1.6.3/.stack-work/install/x86_64-osx/lts-9.14/8.0.2/bin
Registering stack-1.6.3...
Completed 179 action(s).
Copying from /private/var/folders/hw/p4bp49hd7v9_1j60sjvmhqnr0000gn/T/stack-upgrade57634/stack-1.6.3/.stack-work/install/x86_64-osx/lts-9.14/8.0.2/bin/stack to /Users/foo/.local/bin/stack

Copied executables to /Users/foo/.local/bin:
- stack

WARNING: Installation path /Users/foo/.local/bin not found on the PATH environment variable

絶対パスで確認するとインストールされています。

$ /Users/foo/.local/bin/stack  --version
Version 1.6.3 x86_64 hpack-0.20.0
$

リンクを付け替えます。

$ ls -al /usr/local/bin | grep stack
lrwxr-xr-x    1 foo  admin        45 11 12  2016 resolve_stack_dump -> ../Cellar/mysql/5.7.16/bin/resolve_stack_dump
lrwxr-xr-x    1 root        admin        43 10 30  2016 stack -> /Library/Haskell/ghc-8.0.1-x86_64/bin/stack
$ ln -s /Users/ogawanaoto/.local/bin/stack /usr/local/bin/stack
ln: /usr/local/bin/stack: File exists
$ ln -sf /Users/ogawanaoto/.local/bin/stack /usr/local/bin/stack
$ stack --version
Version 1.6.3 x86_64 hpack-0.20.0