さっきハマったエラーを解決したので、備忘のためのメモです。
RStudioとRの両方で試したのですが、{panelvar}というパッケージをインストールしようとしたら、依存パッケージのコンパイルのエラーがでて進めなくなりました。
最初、Rの古いバージョンでやってたら{progress}というパッケージで躓いたんですが、Rを最新版にアプデしてからやると今度は{vctrs}というパッケージがインストールできてませんでした。
{vctrs}だけをインストールしようとしてもエラーが出る。
ERROR: compilation failed for package ‘vctrs’ * removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/vctrs’ Warning in install.packages : installation of package ‘vctrs’ had non-zero exit status The downloaded source packages are in ‘/private/var/folders/7y/j9v534hs3hb971070xnz91l80000gp/T/Rtmp9EalBG/downloaded_packages’
Error: package or namespace load failed for ‘panelvar’: .onLoad failed in loadNamespace() for 'pillar', details: call: utils::packageVersion("vctrs") error: there is no package called ‘vctrs’
* installing *source* package ‘vctrs’ ... ** package ‘vctrs’ successfully unpacked and MD5 sums checked ** using staged installation ** libs clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c arg-counter.c -o arg-counter.o clang: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' [-Wmissing-sysroot] In file included from arg-counter.c:1: In file included from ./vctrs.h:2: /Library/Frameworks/R.framework/Resources/include/R.h:55:11: fatal error: 'stdlib.h' file not found # include <stdlib.h> /* Not used by R itself, but widely assumed in packages */ ^~~~~~~~~~ 1 error generated. make: *** [arg-counter.o] Error 1 ERROR: compilation failed for package ‘vctrs’ * removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/vctrs’ Warning in install.packages : installation of package ‘vctrs’ had non-zero exit status The downloaded source packages are in ‘/private/var/folders/7y/j9v534hs3hb971070xnz91l80000gp/T/Rtmp9EalBG/downloaded_packages’
これは、こないだのMac OSのアプデ時に、X Code最新化(コマンドラインツールのインストール)しておくべきだったのが原因のようです。
下記のサイトで2段階の解決方法が紹介されてますが、私は1段階目の"xcode-select"で治りました。
_cgo_export.c:3:10: fatal error: 'stdlib.h' file not found の解決方法 - Qiita