stylish-haskell のインストールに手こずった件
環境
- macOS High Sierra 10.13.6
- stack 1.7.1
経緯と対処
stylish-haskellをインストールしたい
stack install stylish-haskell
stylish-haskellを見て、上のように打って実行してみると...
問題1
(中略)
`gcc' failed in phase `Assembler'. (Exit code: 1)
と表示されて止まってしまいました1。
問題1の対処
そこで、~/.stack/programs/x86_64-osx/ghc-8.2.2/lib/ghc-8.2.2 にある settings というファイルをいじります。
[("GCC extra via C opts", " -fwrapv -fno-builtin"),
("C compiler command", "gcc"),
("C compiler flags", " -m64 -fno-stack-protector"),
("C compiler link flags", " -m64 "),
- ("C compiler supports -no-pie", "YES"),
+ ("C compiler supports -no-pie", "NO"),
...
C compiler supports -no-pie の行の YES を NO に変えて実行してみると...
問題2
今度は
(中略)
|
30 | # error __STDC_VERSION__ does not advertise C99 or later
| ^
`gcc' failed in phase `C Compiler'. (Exit code: 1)
と表示されて止まってしまいました。
問題2の対処
そこで再び、~/.stack/programs/x86_64-osx/ghc-8.2.2/lib/ghc-8.2.2 にある settings というファイルをいじります。
[("GCC extra via C opts", " -fwrapv -fno-builtin"),
("C compiler command", "gcc"),
- ("C compiler flags", " -m64 -fno-stack-protector"),
+ ("C compiler flags", " -m64 -fno-stack-protector -std=c99"),
("C compiler link flags", " -m64 "),
("C compiler supports -no-pie", "NO"),
...
C compiler flags の行に、 -std=c99 を追加します。
(参考) stackoverflow
問題3
さらに
Copying from /Users/user_name/.stack/global-project/.stack-work/install/x86_64-osx/lts-11.13/8.2.2/bin/stylish-haskell to /Users/tomo/.local/bin/stylish-haskell
Copied executables to /Users/user_name/.local/bin:
- stylish-haskell
Warning: Installation path /Users/user_name/.local/bin
not found on the PATH environment variable.
と出てきてしまいました。
問題3の対処
~/.bashrc や ~/.zshrc 等に次の1行を追加します。
export PATH="/Users/user_name/.local/bin:$PATH"
(参考) github
まとめ
~/.stack/programs/x86_64-osx/ghc-8.2.2/lib/ghc-8.2.2 にある settings というファイルの次の2行を以下のように変更すると解決しました。
("C compiler supports -no-pie", "YES"),
("C compiler flags", " -m64 -fno-stack-protector"),
("C compiler supports -no-pie", "NO"),
("C compiler flags", " -m64 -fno-stack-protector -std=c99"),
-
「問題1」のエラーメッセージが1行分しか残っていませんでした。申し訳ありません。 ↩