- ShellCheck
- LinuxでのShellCheckのインストール
- [email protected]を–without-glibcで入れられるように
- without-glibcな[email protected]でトライ
- without-glibcな[email protected]でトライ
- [email protected]とか
- gccとか全部なしでやって見る
- 直接cabal install
- 諦めて直接
- MacでのShecllCheck
ShellCheck
ShellCheckはシェルスクリプトの文法をチェックしてくれるツールで、 Vimとかと連携しておくと捗ります。
LinuxでのShellCheckのインストール
インストールするのはCentOS 7です。
LinuxbrewがHomebrewに統合されたのを機に、 ユーザーローカルエリアにインストールするツールはLinuxでもHomebrewで行うようにしてきました。
その話は随分前の話なんですがなんですが、今更ShecllCheckが入ってないことに気が付きました。
ということでインストールしてみようとすると、
$ brew install shellcheck
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.
==> Installing dependencies for shellcheck: pandoc
==> Installing shellcheck dependency: pandoc
==> Downloading https://hackage.haskell.org/package/pandoc-2.9.1.1/pandoc-2.9.1.1.tar.gz
Already downloaded: /home/user/.cache/Homebrew/downloads/4292bf61443a19f2a8957e8af9c220e56e8b2d83a1497b14fbbb1715811569f5--pandoc-2.9.1.1.tar.gz
==> cabal v1-sandbox init
==> cabal v1-update
==> cabal v1-sandbox init
==> cabal v1-install --jobs=32 --max-backjumps=100000 --only-dependencies
Last 15 lines from /home/user/.cache/Homebrew/Logs/pandoc/04.cabal:
2020-XX-XX XX:XX:XX +0900
cabal
v1-install
--jobs=32
--max-backjumps=100000
--only-dependencies
gcc-5: error: unrecognized command line option '-no-pie'
`gcc-5' failed in phase `C Compiler'. (Exit code: 1)
READ THIS: https://docs.brew.sh/Troubleshooting
というエラー。 探してみるとこんなIssueが。
shellcheck fails to install · Issue #10694 · Homebrew/linuxbrew-core
ここで
brew install [email protected]
brew install shellcheck -svd --cc=gcc-8
というのがありますが、ちょっと注意が必要なのは何も考えずに[email protected]
を入れると
glibc
が入って環境によっては問題が起こる点。
gcc
には--without-glibc
というオプションがあるのですが、[email protected]
のFormulaにはその様なオプションはありません。
ということで仕方ないので自作。
homebrew-rcmdnkpac/[email protected] at master · rcmdnk/homebrew-rcmdnkpac
[email protected]のFormula に gccのFormula のglibcのところをちょっと足しただけですが。
これで、Linuxで
$ brew install rcmdnk/rcmdnkpac/[email protected] --without-glibc
でglibcなしで[email protected]が入れられます。
これでOK、と思ってたら
$ brew install shellcheck --cc=gcc-8
Warning: You passed `--cc=gcc-8`.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience while you are running this unsupported configuration.
==> Installing dependencies for shellcheck: pandoc
==> Installing shellcheck dependency: pandoc
Error: An exception occurred within a child process:
RuntimeError: The requested Homebrew GCC was not installed. You must:
brew install [email protected]
どうやら--cc
オプションはHomebrewの中でFormulaから処理しているらしく、
[email protected]
の名前で入ってないとだめ、ということに。。。
同じ名前のFormulaを別のTapで入れるとconflictを起こして問題になるので、 Linuxbrew-coreのFormulaをアップデートするしかありません。
[email protected]を–without-glibcで入れられるように
gccのFormulaを参考にすれば簡単にできるので[email protected]なども--without-glibc
出来るように変更。
Pull Requestを出してある状態ですが、とりあえず自分でFormula([email protected]など)を
~/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
にコピーしてインストール。
$ brew install [email protected] --without-glibc
入りました。
すでにPull Requestはマージされてるのでbrew update
すれば[email protected]
なども--without-glibc
で入れられるはずです。
without-glibcな[email protected]でトライ
これでもう一度トライ:
$ brew install shellcheck -svd --cc=gcc-8
...
Downloaded aeson-1.4.6.0
Starting aeson-1.4.6.0
Building JuicyPixels-3.3.4
Building aeson-1.4.6.0
Completed hxt-9.3.1.18
Failed to install JuicyPixels-3.3.4
Build log ( /tmp/pandoc-20200115-158652-15h1ohp/pandoc-2.9.1.1/.cabal-sandbox/logs/ghc-8.8.1/JuicyPixels-3.3.4-683Rg9ZKIIHL6oz4xD5Bes.log ):
cabal: Entering directory '/tmp/cabal-tmp-158859/JuicyPixels-3.3.4'
Configuring JuicyPixels-3.3.4...
Preprocessing library for JuicyPixels-3.3.4..
Building library for JuicyPixels-3.3.4..
[ 1 of 30] Compiling Codec.Picture.InternalHelper ( src/Codec/Picture/InternalHelper.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/InternalHelper.o )
[ 2 of 30] Compiling Codec.Picture.Metadata.Exif ( src/Codec/Picture/Metadata/Exif.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Metadata/Exif.o )
[ 3 of 30] Compiling Codec.Picture.Metadata ( src/Codec/Picture/Metadata.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Metadata.o )
[ 4 of 30] Compiling Codec.Picture.Tiff.Internal.Types ( src/Codec/Picture/Tiff/Internal/Types.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Tiff/Internal/Types.o )
[ 5 of 30] Compiling Codec.Picture.Tiff.Internal.Metadata ( src/Codec/Picture/Tiff/Internal/Metadata.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Tiff/Internal/Metadata.o )
[ 6 of 30] Compiling Codec.Picture.Types ( src/Codec/Picture/Types.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Types.o )
<command line>: /lib/libz.so: wrong ELF class: ELFCLASS32
cabal: Leaving directory '/tmp/cabal-tmp-158859/JuicyPixels-3.3.4'
Completed cryptonite-0.26
Completed aeson-1.4.6.0
cabal: Error: some packages failed to install:
JuicyPixels-3.3.4-683Rg9ZKIIHL6oz4xD5Bes failed during the building phase. The
exception was:
ExitFailure 1
/home/user/.linuxbrew/opt/curl/bin/curl --version
java -version
/home/user/.linuxbrew/Homebrew/Library/Homebrew/build.rb (Formulary::FormulaLoader): loading /home/user/.linuxbrew/Homebrew/Library/Taps/linuxbrew/homebrew-xorg/Formula/xorg.rb
で止まってしまいます。
Failed to install JuicyPixels-3.3.4
Build log ( /tmp/pandoc-20200115-158652-15h1ohp/pandoc-2.9.1.1/.cabal-sandbox/logs/ghc-8.8.1/JuicyPixels-3.3.4-683Rg9ZKIIHL6oz4xD5Bes.log ):
の辺が失敗している模様。
このログを見てみると
cabal: Entering directory '/tmp/cabal-tmp-158859/JuicyPixels-3.3.4'
Configuring JuicyPixels-3.3.4...
Preprocessing library for JuicyPixels-3.3.4..
Building library for JuicyPixels-3.3.4..
[ 1 of 30] Compiling Codec.Picture.InternalHelper ( src/Codec/Picture/InternalHelper.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/InternalHelper.o )
[ 2 of 30] Compiling Codec.Picture.Metadata.Exif ( src/Codec/Picture/Metadata/Exif.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Metadata/Exif.o )
[ 3 of 30] Compiling Codec.Picture.Metadata ( src/Codec/Picture/Metadata.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Metadata.o )
[ 4 of 30] Compiling Codec.Picture.Tiff.Internal.Types ( src/Codec/Picture/Tiff/Internal/Types.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Tiff/Internal/Types.o )
[ 5 of 30] Compiling Codec.Picture.Tiff.Internal.Metadata ( src/Codec/Picture/Tiff/Internal/Metadata.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Tiff/Internal/Metadata.o )
[ 6 of 30] Compiling Codec.Picture.Types ( src/Codec/Picture/Types.hs, dist/dist-sandbox-4b7509f0/build/Codec/Picture/Types.o )
<command line>: /lib/libz.so: wrong ELF class: ELFCLASS32
cabal: Leaving directory '/tmp/cabal-tmp-158859/JuicyPixels-3.3.4'
どうも/lib/libz.so
を見てるのが悪いようですが、
~/.linuxbrew/lib/libz.so
にもちゃんとHomebrewで入れたのが入っていて、
環境変数LD_LIBRARY_PATH
にも~/.linuxbrew/lib/libz.so
は入っています。
without-glibcな[email protected]でトライ
もう一つ新しいgccがあるのでそれを入れてみる
$ brew install [email protected] --without-glibc
Updating Homebrew...
==> Auto-updated Homebrew!
Updated Homebrew from 13f508d0d to 50354852f.
No changes to formulae.
==> Downloading https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz
==> ../configure --with-bugurl=https://github.com/Homebrew/linuxbrew-core/issues --disable-multilib --prefix=/home/user/.linuxbrew/Cellar/[email protected]/9.2.0_1 --libdir=/home/user/.linuxbrew/Cellar/[email protected]/9.2.0_1/lib/gcc/9 --enable-languages=c,c++,objc,obj-c++,fortran --disable-nls --enable-checking=release --program-suffix=-9 --with-gmp=/home/user/.linuxbrew/opt/gmp --with-mpfr=/home/user/.linuxbrew/opt/mpfr --with-mpc=/home/user/.linuxbrew/opt/libmpc --with-isl=/home/user/.linuxbrew/opt/isl --with-pkgversion=Homebrew GCC 9.2.0_1 --without-glibc
==> make
Last 15 lines from /home/user/.cache/Homebrew/Logs/[email protected]/02.make:
/bin/sh ../../gcc/../move-if-change tmp-constrs.h tm-constrs.h
/bin/sh ../../gcc/../move-if-change tmp-preds.c insn-preds.c
echo timestamp > s-constrs-h
/bin/sh ../../gcc/../move-if-change tmp-preds.h tm-preds.h
echo timestamp > s-preds
/bin/sh ../../gcc/../move-if-change tmp-condmd.c build/gencondmd.c
echo timestamp > s-preds-h
echo timestamp > s-conditions
rm gcc.pod
make[3]: Leaving directory `/tmp/[email protected]/gcc-9.2.0/build/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/tmp/[email protected]/gcc-9.2.0/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/tmp/[email protected]/gcc-9.2.0/build'
make: *** [all] Error 2
sh: line 1: 193696 Segmentation fault /usr/bin/gcc --version 2> /dev/null
READ THIS: https://docs.brew.sh/Troubleshooting
These open issues may also help:
llvm: can't pick up gcc-toolchain if run from opt/llvm/bin/clang++ https://github.com/Homebrew/linuxbrew-core/issues/18601
ここでsegmentation fault…
これは面倒なのでこれ以上見てません。。。
[email protected]とか
もうちょっと前のgccを使ってみてもインストールは出来ましたがshellcheckのインストールで
[email protected]
の場合と同じようになりました。
gccとか全部なしでやって見る
その他、gcc
自体もbrew rm
して、とかもやってみましたが何も上手く行かず。。。
Homebrewではどうやってもうまく行きません。
直接cabal install
shellcheckのインストール時に、cabal
を使っているので直接使ってみる
$ cabal install ShellCheck
が、これも最初のものと同じエラーが出ます。。。
諦めて直接
のREADMEに従ってpre-compiledされたものを入れてしまうことにしました。
$ scversion="stable"
$ wget -qO- "https://storage.googleapis.com/shellcheck/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
$ cp shellcheck-${shellcheck} ~/usr/bin
もうこれで良しとしておきます。。。
MacでのShecllCheck
Macでも確認したらなぜか入ってなくてHomebrewで再インストールしたのですが、
その際にBrewfileにすでにあるよ、という
homebrew-file
のwarningが出て、おかしいなと思って
Brewfile
の履歴を見るとshellcheck
自体は2017年に追加されてそのままでした。
それだと前のMacのときのものなので、Mac新しくしてからずっと使ってなかった?
(でも最近でもVimでシェルスクリプトのチェックを見たような気がするが。。。)
確かに再インストール前はVim+Aleでチェックが効いてなかったのが、
インストール後には効くようになりました、当たり前だけど。
なぞ。。。