環境
OS
Darwin HOSTNAME 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan 9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64
XCode
Version 8.2.1 (8C1002)
R
R version 3.3.3 (2017-03-06) -- "Another Canoe"
症状
tidyverseのインストールでコケる。下記のようなエラーが出て、xml2のインストールに失敗する。
install.packages('tidyverse')
...
...
(省略)
...
...
ld: file not found: /usr/lib/system/libsystem_symptoms.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [xml2.so] Error 1
ERROR: compilation failed for package ‘xml2’
* removing ‘/usr/local/lib/R/3.3/site-library/xml2’
Warning in install.packages :
installation of package ‘xml2’ had non-zero exit status
ERROR: dependency ‘xml2’ is not available for package ‘rvest’
* removing ‘/usr/local/lib/R/3.3/site-library/rvest’
Warning in install.packages :
installation of package ‘rvest’ had non-zero exit status
ERROR: dependencies ‘rvest’, ‘xml2’ are not available for package ‘tidyverse’
* removing ‘/usr/local/lib/R/3.3/site-library/tidyverse’
Warning in install.packages :
installation of package ‘tidyverse’ had non-zero exit status
対処法
エラーでググると下記のStackOverflowが引っかかる。Xcodeのバグらしい。
Raymond Naseefさんの次の回答にあるコマンドを実行するとdylibへの参照が消えてコンパイルできるようになる。自分の環境ではこれでインストールできるようになりました。
引用コマンド(2017/03/14閲覧)
sudo /usr/bin/sed -i.backup -E -e 's@/usr/lib/system/libsystem_symptoms.dylib(, )?@@' \
$(grep -ril /usr/lib/system/libsystem_symptoms.dylib \
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib)