中野智文のブログ

データ・マエショリストのメモ

自宅macのJuliaLang環境を治す

背景

色々不具合があるので修正しよう。

brew doctor のメッセージ

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  cloog
  cloog018-julia
  gmp4-julia
  isl
  isl011-julia
  suite-sparse42-julia

取り敢えずこんな感じで実行してみよう。

brew link cloog gmp4-julia isl suite-sparse42-julia

すると、

Linking /usr/local/Cellar/cloog/0.18.4_1... 8 symlinks created
Linking /usr/local/Cellar/gmp4-julia/4.3.2...
Error: Could not symlink include/gmp.h
Target /usr/local/include/gmp.h
is a symlink belonging to gmp. You can unlink it:
  brew unlink gmp

To force the link and overwrite all conflicting files:
  brew link --overwrite gmp4-julia

To list all files that would be deleted:
  brew link --overwrite --dry-run gmp4-julia

とりあえず、次を実行

brew unlink gmp4
brew link --overwrite gmp4-julia

そんな感じで次を実行。

brew link cloog018
brew link --overwrite cloog018-julia
brew link isl
brew link --overwrite isl011-julia
brew link suite-sparse42-julia

とりあえず何も出なくなった。

julia 起動時のエラーメッセージ

WARNING: Error during initialization of module GMP:
ErrorException("The dynamically loaded GMP library (version 4.3.2 with __gmp_bits_per_limb == 64)
does not correspond to the compile time version (version 6.1.2 with __gmp_bits_per_limb == 64).
Please rebuild Julia.")
WARNING: Error during initialization of module LinAlg:
ErrorException("could not load library "libopenblas"
dlopen(libopenblas.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib
  Referenced from: /usr/local/opt/openblas-julia/lib/libopenblas.dylib
  Reason: image not found")
WARNING: Error during initialization of module CHOLMOD:
ErrorException("could not load library "libcholmod"
dlopen(libcholmod.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib
  Referenced from: /usr/local/opt/openblas-julia/lib/libopenblasp-r0.2.19.dylib
  Reason: image not found")

相当やられているに違いない。

決断はすばやく。次のコマンドを実行

$ brew uninstall julia

すると、

Uninstalling /usr/local/Cellar/julia/0.5.1... (752 files, 143.6MB)
julia 0.5.0 is still installed.
Remove all versions with `brew uninstall --force julia`.

はい。やります。

そして julia をアンインストールし、インストールし直す。

はい。また同じエラー

面倒だなー。

homebrew 全部消去

もう面倒だからこれで。悩む必要など無い。このリンクの不具合など到底直せるわけがない。

brew remove --force --ignore-dependencies $(brew list)

emacs とか、font とか消えていったような気がしたな…。まあいいか。

再インストール時のメッセージ。

==> Installing julia from staticfloat/julia
==> Installing dependencies for staticfloat/julia/julia: gmp, mpfr, libmpc, isl, gcc, libffi, staticfloat/julia/llvm37-julia, pcre2, fftw, openssl, libssh2, libgit2, mbedtls, staticfloat/julia/openblas-julia, staticfloat/julia/arpack-julia, staticfloat/julia/suite-sparse-julia

次のメッセージでインストールが完了した。

Documentation and Examples have been installed into:
/usr/local/opt/julia/share/julia

Test suite has been installed into:
/usr/local/opt/julia/share/julia/test

To perform a quick sanity check, run the command:
brew test -v julia

To crunch through the full test suite, run the command:
/usr/local/opt/julia/bin/julia -e "Base.runtests()"
==> Summary
🍺  /usr/local/Cellar/julia/0.5.1: 752 files, 143.6MB

念のためテスト

brew test -v julia

すごいいっぱいエラーが出るんですけど。

dlopen(libopenblas.dylib, 1): Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib

とりあえず、現状確認。

$ ls /usr/local/opt/gcc/lib/gcc/
7

ほう?

今なら何も消えても怖くはない。

cd /usr/local/opt/gcc/lib/gcc
ln -s 7 6

どりゃ。

/usr/local/opt/gcc/lib/gcc/7/libgfortran.4.dylib

はあるみたいだけど、libgfortran.3.dylib はないらしい。

つづきは、

nakano-tomofumi.hatenablog.com